Within my angularjs application, I have implemented an element directive that is equipped with an event listener. This listener is designed to respond to a broadcast event from the controller.
app.directive('listItem', function(){
return {
link: function(scope, element){
scope.$on('controllerEvent', function(e,attr) {
console.log('event fired!')
});
},
templateUrl:'views/fragments/list.html'
}
}]);
The directive in question is used multiple times within my view through the ng-repeat directive and an array.
Upon loading the view, all listeners are triggered appropriately when the event occurs. However, when a new item is added to the array leading to another instance of the directive being rendered, its corresponding listener does not execute. Is there a way to manually ensure that it binds?