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

前端 未结 7 1798
醉话见心
醉话见心 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条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-30 00:46

    +1 for Batarang

    Also, you can get the scope from any element in the DOM by executing the following from the console

    angular.element(DOMNODE).scope()
    

    Where DOMNODE, is of course, a reference to a DOM node.

    For example, in Chrome in the elements tab you can select the node where the ng-app directive is, and get the root scope with

    angular.element($0).scope()
    

提交回复
热议问题