AngularJS : broadcast event from directive

后端 未结 3 1930
南旧
南旧 2020-12-07 18:35

I\'ve seen people doing this from wherever in their code:

$rootScope.$broadcast(\'someEvent\', someParameter); 

and then in some controller

3条回答
  •  余生分开走
    2020-12-07 19:06

    It's usually a good idea not to use the $rootScope as it's global and you shouldn't pollute it unless you really know what you're doing. I would recommend that you read this article about communication between services, directives and controllers.

提交回复
热议问题