1
I have the following "broadcast" inside a "Directive":
console.log('a emitir...');
$rootScope.$broadcast('olamundo', params);
In my "controller" I have the following code:
$scope.$on('olamundo', function (event, args) {
console.log('a escutar...');
//aqui vai o código
});
My "olamundo" event is running 2 times, the phrase "listening..." appears 2 times on the console (due to the "console.log" in the code above).
In the "Directive" where "broadcast" is issued, the phrase 'to emit...' appears once feathers.
There is no other "broadcast" with the same name, because the 'olamundo' event is running 2 times?
It would be possible for you to make a functional example on Plunkr? Without seeing the rest of the code you can’t be sure what’s causing the problem.
– André Ribeiro