In angularJs, the $broadcast (), parent transmits data to the son, why can't he receive the duck?

< body ng-app= "app" >

<div ng-controller="parentContrl">
    <h1>{{name}}</h1>
    <div ng-controller="childContrl">
        <h1>{{message}} </h1>
    </div>
</div>

< / body >

< / html >
< script >

var app = angular.module("app", []);

app.controller("parentContrl", ["$scope", function ($scope) {
    $scope.name = "hello"
    $scope.$broadcast("call", $scope.name)
}]);

app.controller("childContrl", ["$scope", function ($scope) {
    $scope.$on("call", function (e, data) {
        $scope.message = data;
    })
}])

< / script >

Feb.23,2022

< H2 > reason: < / H2 >

Controller instantiation sequence causes.

< H2 > add: < / H2 > The instantiation of the

Controller is instantiated according to the location order of the html, so the parent class Controller is instantiated first, and the broadcast is sent, while the subclass does not complete the registration of the broadcast monitoring registration. Lose this broadcast.

you can delay the parent broadcast, or change it to broadcast after clicking, and the subclass can receive it normally
.
Menu