Thursday, 15 May 2014

angularjs - ngResource $save is wiping out models -



angularjs - ngResource $save is wiping out models -

i create new model new mymodel({description: 'default'})

later, save it.

$scope.mymodel.$save(function(updated){ stuff here? });

my problem $save method wiping out fields. why happen?

$scope.mymodel.$save(function(updated){ updated.description - undefined $scope.mymodel.description - undefined });

the thing i've found works right this:

var re-create = angular.copy($scope.mymodel); $scope.mymodel.$save(function(updated){ copy.description - not undefined });

this seems contradict docs. what's going on?

check server side, think don't have description field in server side model. happend? $scope.mymodel passed server , updated response object, response object not contain description field

angularjs angular-resource ngresource

No comments:

Post a Comment