Angular.js boradcast error: $ rootScope.broadcast is not a function

I am adding elements dynamically to an array of elements and would like the directive to know that there are new elements. Therefore, inside the addItem () controller function, I am trying to do the following:

setTimeout(function(){ $rootScope.broadcast("itemAdded"); // I also tried: $scope.broadcast("itemAdded"); which isn't working }); 

Problem: I get an error:

 $rootScope.broadcast is not a function 

Any clues? With pleasure send more code if you need additional information.

+4
source share
1 answer

His typo:

 $rootScope.$broadcast(name, args) 
+10
source

All Articles