Reputation: 6943
I have a service that looks like this:
angular.module('myApp').service('NodeService', ['$resource', function ($resource) {
'use strict';
...
JMSStats:{
url: "/some/restUrl",
method: 'GET',
isArray: true,
},
....
and in my controller
NodeService.JMSStats({ id: nodeId }, function(data){
console.log(data);
});
the data looks like it is a promise rather than the actual data. That is fine and makes sense, but I have to use that data here in the controller.
How can I set it to have a callback of some sort for when the data resolves?
I tried something like this:
data.$promise.finally(function(){
console.log(data);
});
but data still is set to the promise.
Upvotes: 1
Views: 27
Reputation: 44386
I think what you want is
data.$promise.then(function(d){
console.log(d);
});
Upvotes: 1