I'm looking to have a bit of a cleaner controller to not muddy it up with promise api stuff.
Here's an example of what I'm talking about:
Some Service
...
.service('SomeService', function SomeService($http) {
this.getAllItems = function() {
return $http.get('api/items')
.success(function(data) {
return data;
});
Controller
...
SomeService.getAllItems().then(function(response) {
$scope.items = response.data;
});
...
I'm trying to avoid the extra function call on the promise and assign items directly like so:
$scope.items = SomeService.getAllItems();
Is this possible? I've tried calling the then within the service, and it still ends up returning a promise object once it's resolved in the controller, but I'm probably doing something wrong. Thanks!
.then()?.then()callback delegates once the response is received, otherwise it'd block?