how to debug the $rootScope object of angularjs in the browser

前端 未结 7 1753
醉话见心
醉话见心 2021-01-29 23:43

Is there a way of debugging the angularjs application when it is loaded in the browser?

ie. I wish to get the $rootScope of my current application. How woul

7条回答
  •  Happy的楠姐
    2021-01-30 00:29

    For those using $compileProvider.debugInfoEnabled(false); and ng-strict-di just paste this in the console and $rootScope will be logged and added to window:

    function getRootScope($rootScope){ console.log(window.$rootScope = $rootScope); }
    getRootScope.$inject = ["$rootScope"];
    angular.element(document.querySelector('[data-ng-app],[ng-app]')).injector().invoke(getRootScope);
    

提交回复
热议问题