Last active
August 29, 2015 14:13
-
-
Save felixzapata/6af05239585cec8e580f to your computer and use it in GitHub Desktop.
How to access the angular $scope variable in browser's console?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/13743058/how-to-access-the-angular-scope-variable-in-browsers-console | |
angular.element($0).scope() | |
// Access whole scope | |
angular.element(myDomElement).scope(); | |
// Access and change variable in scope | |
angular.element(myDomElement).scope().myVar = 5; | |
angular.element(myDomElement).scope().myArray.push(newItem); | |
// Update page to reflect changed variables | |
angular.element(myDomElement).scope().$apply(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment