Dine
Dine

Reputation: 7283

angular.js broadcast error: $rootScope.broadcast is not a function

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

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

Problem: I'm getting the error:

$rootScope.broadcast is not a function

Upvotes: 6

Views: 6502

Answers (1)

Ajay Singh Beniwal
Ajay Singh Beniwal

Reputation: 19037

Its a typo its :

$rootScope.$broadcast(name, args)

Upvotes: 12

Related Questions