angularjs - Error when trying to post using $resource -


i using following calls entityservice.postentity function:

   entityservice.postentity($scope.entitytype, formdata)    .then(function (result) {       $scope.grid.data.push(result);    }, function (result) {       alert("error: " + result);    }) 

here's entity resource , postentity function:

   var entityresource = $resource('/api/:entitytype', {}, {       postentity: { url: '/api/:entitytype/', method: 'post' },    });     postentity: function (entitytype, entity) {       var deferred = $q.defer();       entityresource.postentity({ entitytype: entitytype }, entity,          function (resp) {                deferred.resolve(resp);          }, function (resp) {                deferred.reject(resp.data.exceptionmessage);          });          return deferred.promise;    }, 

the above works me.

now tried replace with:

 var entityresource = $resource('/api/' + $scope.entitytype + '/');  entityresource.save({}, formdata)     .success(function (data, status, headers, config) {        var = data;     })     .error(function (data, status, headers, config) {        var b = data;     }); 

it's giving me error:

object #<b> has no method 'success' 

can give me advice on might doing wrong.

$resource returns $then. use this:

var mything = $resource(...); var myresult = mything.save({}, formdata); myresult.$then(function(data){}, function(data){}); //             success           failure 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -