angularjs - Trying to make a $resource call from a controller through a model to a service, can't get the response back to the controller -


i've got controller has dependency on model. calls

accountmodel.saveaccount(vm.account,function(data){             response = data;         },function(data){             response = data;         }); 

the model calls service's save function:

return accountservice.save(request,function(resp){             return resp;         },function(resp){             return resp;         }); 

and function looks this:

function save(account) {         return accountresource.save(account, function (resp) {             return resp;         }, function (resp) {             return resp;         });      } 

the idea save function return response model return controller, other stuff later. however, none of happening.

response (in controller) remains undefined. how can fix this?

angular's service works little different, save method returns , object:

{$promise: promisvevalue, $resolve: something} 

so use properly:

myresource.save(resouceobj, handler); 

or

myresource.save().$promise.then(handler); 

this draft of should do, try integrate code.


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -