Skip to content

Instantly share code, notes, and snippets.

@felixzapata
Last active August 29, 2015 14:13
Show Gist options
  • Save felixzapata/6af05239585cec8e580f to your computer and use it in GitHub Desktop.
Save felixzapata/6af05239585cec8e580f to your computer and use it in GitHub Desktop.
How to access the angular $scope variable in browser's console?
// 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