Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 388
Dine Avatar asked Apr 25 '13 11:04

Dine


1 Answers

Its a typo its :

$rootScope.$broadcast(name, args)
like image 109
Ajay Beniwal Avatar answered Sep 25 '22 17:09

Ajay Beniwal