<DivNg-controller="Parentctrl" ><!--Parent-To<DivNg-controller="Selfctrl" ><!--Yourself--<Ang-click= "click ()" >click me</a> span class= "tag" ><div ng-controller= "Childctrl" ></div> <!-- children--</ div> <div ng-controller= "Broctrl" ></ div> <!-- lateral--></DIV>
App.controller (' Selfctrl ', function ($scope) { $scope. Click =function () { $scope.$broadcast (' To-child ',' Child '); $scope.$emit (' To-parent ',' Parent ');}}); App.controller (' Parentctrl ', function ($scope) { $scope.$on (' To-parent ', function (event,data) { Console.log (' Parentctrl ', data);//The parent can get the value}); $scope.$on (' To-child ', function (event,data) { Console.log (' Parentctrl ', data);//Children cannot get a value});}); App.controller (' Childctrl ', function ($scope) { $scope.$on (' To-child ', function (event,data) { Console.log (' Childctrl ', data);//The child can get the value}); $scope.$on (' To-parent ', function (event,data) { Console.log (' Childctrl ', data);// parent not getting value ' Broctrl ', function ( $scope) { span class= "variable" > $scope. $on ( ' to-parent ', function (event,data) { Console.log ( ' Broctrl ', data); // is not value $scope. $on ( ' To-child ', function (event,data) { Console.log ( ' Broctrl ', data); // is not a value
Angular between controllers is worth passing