问题描述
是否可以通过Chrome的控制台找到元素的控制器?我可以通过在元素面板中选择元素并使用
Is there a way to find the controller for an element through Chrome's console? I can get a reference to the component by selecting the element in the Elements Panel and using
var c = angular.element($0);
c
具有一个controller
属性(看起来像一个构造函数),但是我不确定该如何处理.有什么办法可以从这里找到控制器的名称吗?
c
has a controller
property (looks like a constructor), but I'm not sure what to do with this. Is there any way to find the controller's name from here?
推荐答案
如果您执行angular.element($0).scope()
或只是$scope
(如果您安装了Batarang Chrome扩展程序),则应该能够访问所选元素的作用域功能,并且特性.这还应该包括控制器在示波器上公开的所有功能/属性.
If you do angular.element($0).scope()
or just $scope
(if you installed Batarang Chrome extension), you should be able to get access to selected element's scope's functions and properties. This should also include any functions/attributes that a controller has exposed on the scope.
但是,无法获得控制器的名称.
There is no way to get the controller's name, though.
这篇关于从元素角度获取控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!