[英]How to communicate between two controller in my case?
我正在尝试在两个控制器之间进行通信
我有类似的东西
HTML
<div ng-controller='testCtrl'>
<div ng-click='clickBtn()'>clikc me</div>
</div>
..other contents...
<div ng-controller='testTwoCtrl'>
other contents...
</div>
JS
app.controller('testCtrl', function($scope) {
$scope.clickBtn = function(){
alert('hey')
}
}
app.controller('testTwoCtrl', function($scope) {
//is there anyway to know if clickBtn method is called from here?
}
我希望知道是否可以通过单击按钮来通知testTwoCtrl。 谢谢您的帮助!
您可以为clickBtn
函数创建参数。
我建议建立一个布尔参数,然后如果clickBtn
从所谓testTwoCtrl
传递的价值true
,否则你可以让它空在这种情况下,这将是错误的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.