标签:
此处不做详细讲解,提供一个小例子,看了便懂
<html ng-app=""> <div ng-controller="ctrlController"> <div ng-controller="ctrl1Controller"></div> <div ng-controller="ctrl2Controller"></div> </div> </html> <script> function ctrl1Controller($scope){ $scope.$emit(‘event‘, data); } function ctrlController($scope){ $scope.on(‘event‘, function(event, data){ $scope.$broadcast(‘event1‘, data); }) } function ctrl2Controller($scope){ $cope.$on(‘event1‘, function(event, data){ //do some thing }) } </script>
Angular中Controller之间的信息传递(第二种办法):$emit,$broadcast,$on
标签:
原文地址:http://www.cnblogs.com/lodingzone/p/4860485.html