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
Post a Comment