Just starting out with JavaScript and AngularJS, and this particular issue has me stumped.
Requirements
- A RESTful service that retrieves data from the backend
- AngularJS 1.2.21 and Restangular 1.4.0 being used
- An AngularJS controller tasked with requesting an enhanced version of the provided data from the service
Current Setup
The method causing confusion is as follows:
service.getSlices = function() {
Restangular.all('entries').getList().then(function(entries) {
// complex modifications to the data take place here
// ...
return resultOfModification; // intended returned value for getSlices();
})
// need to ensure resultOfModification is returned here
};
The Dilemma
Essentially, I want `getSlices()` to wait until the promise is resolved before returning `resultOfModification` once it's computed.
Another Approach
I have considered returning a promise from `getSlices()` which would deliver `resultOfModification`. However, my understanding may not be sufficient enough at the moment due to frustration or exhaustion.
Any answers or suggestions are greatly appreciated, especially recommendations on helpful resources. Thank you!