Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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