Reputation: 9247
I have this object:
let obj = {'r' : this.queries.r}
this.queries.r is an array. ['ca','ba','es'].
What i want is to assign this obj to queryParams so in url to get:
example.com?r=ca&r=ba&r=es.
Any suggestion how can i do this? I tried with httpParams but its not working.
Upvotes: 0
Views: 413
Reputation: 1379
You could set the query params manually
let obj = {'r' : ['ca','ba','es']}
const r = obj.r[0];
const r2 = obj.r[1];
const r3 = obj.r[2];
const url = window.location.href + '?r=' + r + '&r=' + r2 + '&r=' + r3;
window.history.pushState({}, "", url);
Upvotes: 2