Angular $ rootScope. $ Broadcast () -Ereignis zweimal im Controller abgefangen
Broadcating Event auf Knopfdruck: -
$scope.onButtonClick = function(){
$rootScope.$broadcast('onButtonClick');
}
Und ein Ereignis in einem anderen Controller abfangen: -
$rootScope.$on('onButtonClick',function(event){
alert("catched");
console.log(event);
});
Aber es hat zweimal gefangen, obwohl es nur einmal abgefeuert hat. Warum das