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');