I have a service that make a REST call. When the rest call is complete (i.e. the data is available), I want to call the service's function which process that data.
.service('EventService', function(eventRestApi, $scope) {
var internalData = { messages : [], headers: [], consolidatedEvents : {} }
return {
loadEvents : function(beginTimeMillis, endTimeMillis) {
this.getEvents(beginTimeMillis, endTimeMillis, internalData, null)
.then(function(result){
internalData.consolidatedEvents = this.consolidateEvents(internalData.events)
})
},
getEvents : function() {...},
consolidatedEvents : function() {...},
}
I get an error saying that this doesn't have consolidateEvents. How do I access a function in my service on a callback? Am I approaching this problem wrong?