First of all, parent-child scope relation does matter. You have two possibilities to emit some event: $broadcast -- dispatches the event downwards to all child scopes, $emit -- dispatches the event upwards through the scope hierarchy. If scope of firstCtrl is parent of the secondCtrl scope, your code should work by replacing $emit by $broadcast in firstCtrl : function firstCtrl ( $scope ) { $scope . $broadcast ( 'someEvent' , [ 1 , 2 , 3 ]); } function secondCtrl ( $scope ) { $scope . $on ( 'someEvent' , function ( event , mass ) { console . log ( mass ); }); } In case there is no parent-child relation between your scopes you can inject $rootScope into the controller and broadcast the event to all child scopes (i.e. also secondCtrl ). function firstCtrl ( $rootScope ) { $rootScope . $broadcast ( 'someEvent' , [ 1 , 2 , 3 ]); } Finally, when you need to ...
Such a nice post.#Thanks for sharing this kind of information pc-auto-shutdown-crack You can also visit my Website ukcrack.com
ReplyDelete