Reputation: 713
$rootScope.$on("conv", function() {
var cobject = nservice.getconvo();
console.log("cobject", cobject);
$scope.cnotifications= cobject.convos;
$scope.num_unread= cobject.num_unread;
});
This function is inside a controller.That controller is loading up only on page refresh.Its fethching the data from service when on page refresh.
Upvotes: 1
Views: 836
Reputation: 2013
Well, the simplest solution will be to use events. The service should have a method, which the controller calls, that tells the service to refresh the data (the notifications). Once fresh data is available in the service, the service will throw an event on the rootScope, which the relevant controllers will intercept, and update their models accordingly.
Upvotes: 1