In app.js, I resolve a ui-router thusly:
.state('edit', {
url: '/edit/:id',
templateUrl: '/ang/views/edit/editapp.html',
resolve: {
loan: function ($q, $stateParams, Loans) {
var p = $q.defer();
Loans.getLoan($stateParams.id)
.then(function (res) {
p.resolve(res);
});
return p.promise;
}
},
controller: 'EditAppController'
})
I have a Loans factory where this promise is resolved and in the EditAppController, I send the object back to the factory for further processing using
$scope.loan = Loans.makeLoan(loan.data.data);
Here is the pertinent part of my Loans Factory:
.factory('Loans', function($http){
return {
getLoan: function(id){
return $http.get('/api/loans/' + id);
},
makeLoan: function(o){
o.jwg = 'This added in make loan';
return o;
};
In the makeLoan() method, I just did something to prove to me that this work. What I NEED to do is to make another $http call to the API to get some additional data and I NEED to resolve that call within the same method (makeLoan()) so that I can add some calculations to the object within this function before giving it to the controller for the view.
Can someone explain to me how I can do this?