Angular $rootScope.$broadcast() event caught twice in controller

前端 未结 3 1007
醉梦人生
醉梦人生 2021-02-05 04:27

Broadcating event on button click :-

$scope.onButtonClick = function(){
    $rootScope.$broadcast(\'onButtonClick\');
}

And catching event in

3条回答
  •  粉色の甜心
    2021-02-05 05:14

    As it turned out the multiple controllers were instantiated due to ng-controller declaration in html and also as part of state setup for ui-router.

    The solution is to remove one of the declarations.

提交回复
热议问题