javascript - Posting multiple arrays with $http service in Angular -


i using angular , have 2 arrays post node.js server processed , sent in confirmation email. thoughts on how submit these arrays?

here 2 arrays:

var array1 = vm.contacts; var array2 = vm.projects; 

$http service:

data = array1; // possible add array2 here too?  $http.post('http://localhost:9000/api/emails', data)   .then(function(response) {     console.log(response);    }, function(response) {     console.log('error',response); } 

you send object contains arrays. this:

var vm = {}; vm.contacts = []; // array of contacts. vm.projects = []; // array of projects. var data = vm; // object arrays. 

in $http service:

$http.post('http://localhost:9000/api/emails', data)     .then(function (response) {     console.log(response.data); // use response.data show response. }, function (response) {     console.log('error', response); } 

updated:

by way might send arrays of arrays. this:

var vm = {}; vm.contacts = []; vm.projects = [];  var arrays = []; var array1 = vm.contacts; var array2 = vm.projects;  arrays.push(array1, array2); console.log(arrays); var data = arrays; 

then:

in $http service:

$http.post('http://localhost:9000/api/emails', data)     .then(function (response) {     console.log(response.data); // use response.data show response. }, function (response) {     console.log('error', response); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -