1

I got this following example working with GET.. But 'doSave' is not working for POST. Am I overlooking some?


    $scope.obj1 = $resource('http://localhost:port/srv/:id',
            {port: '\:8080', id:'2', callback: 'JSON_CALLBACK'},
            {get:{method:'JSONP'}, save:{'POST'});


    $scope.doSearch = function () {
    $scope.Result = $scope.obj1.get({id:$scope.term});
    }

    $scope.doSave = function () {
    $scope.Result.save();
    }
1

1 Answer 1

1

Except for the query/get methods, the rest are called prefixed with $ ($resource.$save(), $resource.$remove(), etc)

So in doSave you need

$scope.Result.$save();

More details in the official docs

Sign up to request clarification or add additional context in comments.

2 Comments

I am trying to use $resource with different URL for each GET and POST.. Do you have any idea?
in my case it's making a POST with url-encoded values rather than a json object. but my Results are from .query . is that the problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.