How to create a custom POST request service in Angularjs -
i have simple service that:
packlightapp.factory('hike', ['$resource', function ($resource) { return $resource('app/rest/hikes/:id', {}, { 'query': { method: 'get', isarray: true}, 'get': { method: 'get'}, }); }]);
i want add new method send array backend in order save it. don't know right syntax usecase , how can catch in backend. backend coded in java. example (case of simple post request):
@requestmapping(value = "/rest/hikes", method = requestmethod.post, produces = "application/json") public void create(@requestbody hikedto hikedto) {...}
thanks help.
you can use de 'save' method $resource
app.controller('postctrl', function($scope, hike) { var objectarray = [{data: 1}, {data: 2}]; hike.save({id: 'yourid'}, objectarray, function(response) { console.log(response); // things on success. }); });
Comments
Post a Comment