Hi,
I was trying to resolve the promise in the service and create a
functional constructor and return it to the controller. I find that the
problem here is the asynchronous call that returns after the controller's
call finishes. It looks like that is the reason to use 'then'.
How do I resolve the promise and create a functional constructor like this
?
<!-- My call in the controller -->
asynchcall = AsynchronousService.asynchcall();
<!-- The call in the service that resolves the promise -->
return {
asynchcall:function() {
thatasynchcall = {};
thatasynchcall.getFunctionalConstructor = function(){
return thatasynchcall.functionalconstructor;
};
var deferred = $q.defer();
setTimeout(function() {
//or reject
deferred.resolve({ 'test' : 10, 'test1' : 5 });
}, 1000);
var prom = deferred.promise;
prom.then(function(response) {
console.log( 'Promise is resolved' );
thatasynchcall.functionalconstructor=
factory.functionalconstructor(response);
})
return thatasynchcall;
}
};
Thanks,
Mohan
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.