I\'m new to Angular2. I have a JSON object, as below:
var options = {
param1: \"parama1\",
param2: \"parama2\",
param3: \"parama3\"
};
wh
How about this:
ngOnInit(){
let options = {
param1: "param1",
param2: "param2",
param3: "param3"
};
let myQuery = 'http://someurl?'
for (let entry in options) {
myQuery += entry + '=' + encodeURIComponent(options[entry]) + '&';
}
// remove last '&'
myQuery = myQuery.substring(0, myQuery.length-1)
window.location.href = myQuery;
}
myQuery
value is ?param1=param1¶m2=param2¶m3=param3
.