从元素角度获取控制器 [英] Angular Get Controller from Element

查看:70
本文介绍了从元素角度获取控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过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.

这篇关于从元素角度获取控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆