I am using nginclude to change a partial view, and inside the partial view, I have a controller, and inside that controller, I want to call a function from the parent scope that changes the a variable. How do I do that?
我正在使用nginclude来更改局部视图,在局部视图中,我有一个控制器,并且在该控制器内部,我想从更改变量的父作用域调用一个函数。我怎么做?
1 个解决方案
#1
2
You can use $broadcast
你可以使用$ broadcast
Parent controller:
$scope.$broadcast("myEvent");
Child controller:
$scope.$on("myEvent", function() {
console.log("Running my event");
});
#1
2
You can use $broadcast
你可以使用$ broadcast
Parent controller:
$scope.$broadcast("myEvent");
Child controller:
$scope.$on("myEvent", function() {
console.log("Running my event");
});