angularjs - $scope.$on executing more than once -


i using broadcast , $scope.$on , method in $scope.$on executing multiple times. here code. in controller:

$scope.selectitem = function(index, item){     baseservice.hideview(); },  $scope.$on("closeview",function(){     $log.debug("insideon: calling hidevieweditem");     $scope.hidevieweditem(); }); 

in baseservice :

app.factory('baseservice', function ($rootscope, $log, $location) {     return {        hideview :function(){         $log.debug("calling closeview");         $rootscope.$broadcast("closeview", 1);      }     } });  

here calling hideview once hidevieweditem calling 3 times. in console getting these messages.

calling closeview insideon: calling hidevieweditem insideon: calling hidevieweditem insideon: calling hidevieweditem 

how make call once?


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -