i want to achieve that the queryParams can be dynmamically passed it. For now i can set the values of the params dynamically, but not the keys
Here is my Code
onItemClick(item: FilterItem, group: FilterGroup, i: number) {
let navigationExtras: NavigationExtras = {
queryParams: { name : group.items[i].param }
};
this.router.navigate(['/search'], navigationExtras);
}
I cannot put instead of "name" my group.name which is a string. I tried this:
queryParams: { group.name: group.items[i].param }
But here i get syntax error. How can i put the "key" of a queryParam through an object like that?
This should work:
queryParams: { [group.name]: group.items[i].param }
See also Creating object with dynamic keys
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With