In Angular.js, I have this in my directive:
scope.$watchCollection(function(){
return StatusTrackerService.eventCollection
}, function(){
console.log("ssssssssssss");
console.log(StatusTrackerService);
console.log("ssssssssssss");
});
In my service, I am feeding it StatusTrackerService.eventCollection and add a property to eventCollection:
function runEventCheck(account, eventId) {
url = urlBuilder(account, eventId);
eventCollection[referenceVipLabel.vipLabel] = new NewStatusEvent(account, eventId, url);
}
return { runEventCheck: runEventCheck,
eventCollection: eventCollection,
referenceVipLabel: referenceVipLabel
};
});
When I add a property to eventCollection, $watch does not detect a change. It seems to me adding a property to object eventCollection would change the object. Why isn't $watch detecting this change? I don't really want to use $watchCollection because then it detects any changes to StatusTrackerService.
eventCollectionisStatusTrackerService.eventCollectionright?