I'm unable to get the controller to listen to any emit or broadcast messages. I've tried with $rootScope as well but still it is not working.
<div ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
</div>
<div ng-controller="Controller1">
<p>Hello {{name}}!</p>
</div>
app.controller('MainCtrl', function($scope) {
$scope.name = 'SomeName';
$scope.$broadcast($scope.name, "Hello");
});
app.controller('Controller1', function($scope) {
$scope.name = 'SomeName';
$scope.$on($scope.name, function(event,data) {
console.log("identified");
console.log("data");
});
});