[英]How can I access controller in angular directive
I want to access controller in angular directive. 我想以角度指令访问控制器。 How can I do that? 我怎样才能做到这一点?
I have a link function in the directive and I want to access the controller passed to the directive. 我在指令中有一个链接函数,我想访问传递给该指令的控制器。
The link function's 4th parameter gives you access to the controller instance. 链接功能的第四个参数使您可以访问控制器实例。
return {
template: template,
controller: controller,
controllerAs: 'myCtrl',
restrict: 'E',
replace: true,
link: function(scope, element, attrs, controller) {}
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.