Skip to content

Instantly share code, notes, and snippets.

@magicznyleszek
Last active March 18, 2016 14:05
Show Gist options
  • Save magicznyleszek/d4856831c852385467b0 to your computer and use it in GitHub Desktop.
Save magicznyleszek/d4856831c852385467b0 to your computer and use it in GitHub Desktop.
Debugging AngularJS from console

Debugging AngularJS from console

Note: In Chrome Console, instead of document.querySelector, you can use $0 - $4 to access the last 5 DOM elements selected in the inspector window.

Access Scopes

var fooCtrl = angular.element(document.querySelector('[ng-controller*="fooCtrl"]')).scope();
angular.element(document.body).scope();
angular.element(document.body).isolateScope();

Get any Service

You have to select the element where ngApp was defined.

var fooService = angular.element(document.body).injector().get('fooService');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment