http://jsbin.com/lakujiya/4/edit
请帮助我,我认为这种方法是正确的,但是差值控制器中的$ scope无法像我期望的那样传递变量。我不知道,因为我很新鲜。
您需要在$rootScope.$broadcast
此处使用http://jsbin.com/caravezi/1/edit,
angular.module('myApp',[]).
controller('SomeController', function($scope, $rootScope){
$scope.title = 'have a try.';
$scope.clicked=function(){
$rootScope.$broadcast('someEvent', $scope.title);
}
}).
controller('otherController', function($scope, $rootScope){
$scope.$on('someEvent', function(e,title){
$scope.title = title;
});
})
$emit
-通过范围层次结构向上调度事件。
$broadcast
-将事件向下分发到所有子范围,
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句