angularjs - Sending data from form to POST request in Angular -


i want make post request using angular. using ng-submit submit form controller access factory make request using:

$http.post('/droplets', data) 

i need data form fields put in "data" variable above send api can't work out how when more 1 field. how done?

try this...

$http({         url: '/droplets',         method: "post",         data: json.stringify({application:app, from:data1, to:data2}),         headers: {'content-type': 'application/json'}       }).success(function (data, status, headers, config) {            // callback called asynchronously     // when response available         }).error(function (data, status, headers, config) {             // called asynchronously if error occurs     // or server returns response error status.         }); }; 

ref:https://docs.angularjs.org/api/ng/service/$http


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -