Furthermore, I am using scope.apply because otherwise the callback function did not trigger any watch.
On Thu, Apr 2, 2015 at 1:19 AM, Anurag Sharma <[email protected]> wrote: > Hi, > > I guess it is not a problem of $scope.$apply, I am not quite sure why it > is happening. May be because two SSE events are invoked inside a single > page. > > However, we can use single SSE call(EVENTS:A) rather than using two > different calls. We can attach results of (EVENTS:B) into (EVENTS:A) > itself and parse it as a JSON to use it as "cpu". > > var eventACallback = function(e) { > var pData = JSON.parse(e.data); > var sDate = new Date(Number(pData.date)); > $scope.cpu = pData.cpu; > $scope.day = sDate.toDateString() + " " + sDate. > toLocaleTimeString(); > $scope.modules = pData.modules; > console.log("EVENTA"); > }; > > Using above scenario, there will be no conflicts as there is only single > event callback. > > Also, there no need of using scope.apply, because controller is already > having digest cycle. So scope.apply will be already in running within the > controller. > > Please do let me know if that helps out. > > Thank you, > Anurag. > > -- > You received this message because you are subscribed to a topic in the > Google Groups "AngularJS" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/angular/FCyO0IMU-g0/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
