Hey there, I have another question about promises. I'm trying to fetch data from an endpoint and use it in ng-repeat. Here is the standard response from the endpoint:
{"ebbe5704-4ea5-470e-8ab9-102ee8ca457f":"Foo",
"e380a6f7-2f88-46bb-bd54-251719353627":"Bar"
}
This is how I am handling the promise:
RequestService.getValues().$promise.then(function(res) {
vm.result = res;
});
Then, I display it in HTML like this:
<p ng-repeat="i in vm.result">{{i}}</p>
The issue I'm facing is that the rendered view includes internal fields of the promise ($promise
and $resolved
):
https://i.sstatic.net/AtIFo.png
Am I missing something here? Is there a better way to avoid showing those internal fields without having to filter through the result keys?
UPDATE:
RequestService.getValues
is using $resource
, so the approach can be replaced with:
$resource("/rest/", null, {
getValues: {
url: "/rest/values/",
method: "GET"
}
}).getValues().$promise.then(function(res) {
vm.result = res;
console.log("RES:", res);
});