I'm working with a set of values:
var array = [10,11,12,13,14,15]
and I need to pass them as parameters in an http.get request in this format:
id=10&id=11&id=12&id=13&id=14&id=15
I initially tried the following approach:
var url = /myUrl;
var urlParam;
array.map(function(item) {
urlParam += '&id=' + item ;
return urlParam;
});
However, the resulting URL structure is incorrect:
INCORRECT
/myUrl&id=10&id=11&id=12&id=13&id=14&id=15
It should actually look like this:
/myUrl?id=10&id=11&id=12&id=13&id=14&id=15
when making the call using
$http.get('/myUrl' + urlParam);
Is there a more effective solution to achieve this?