How do I access the $scope variable in browser's console using AngularJS?

前端 未结 19 1569
渐次进展
渐次进展 2020-11-22 08:35

I would like to access my $scope variable in Chrome\'s JavaScript console. How do I do that?

I can neither see $scope nor the name of my mo

19条回答
  •  臣服心动
    2020-11-22 08:50

    Say you want to access the scope of the element like

    You could use the following in the console:

    angular.element(document.querySelector('[ng-controller=hw]')).scope();
    

    This will give you the scope at that element.

提交回复
热议问题