Angular side-by-side scope, the scope does not exist in the relationship between the hierarchy, $scope. $emit $rootscope when it is sent back. $on Receive multiple messages
$rootScope. $on (' Savedraft ',function() {$scope. Savedraft (); }); $rootScope. $on (' Previewposition ',function() {$scope. Previewposition (); }); $rootScope. $on (' Publishjob ',function() {$scope. Publishjob (); }); $scope. Previewposition=function() {$scope. $emit (' Previewposition '); }; $scope. Savedraft=function() {$scope. $emit (' Savedraft '); }; $scope. Publishjob=function() {$scope. $emit (' Publishjob '); };
The right way
$scope. $on (' Savedraft ',function() {$scope. Savedraft (); }); $scope. $on (' Previewposition ',function() {$scope. Previewposition (); }); $scope. $on (' Publishjob ',function() {$scope. Publishjob (); }); $scope. Previewposition=function() {$rootScope. $broadcast (' Previewposition '); }; $scope. Savedraft=function() {$rootScope. $broadcast (' Savedraft '); }; $scope. Publishjob=function() {$rootScope. $broadcast (' Publishjob '); };
Angular $emit $on multiple receive when sending back