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

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -