When I am using either routerLink
or router.navigate
, I face an issue where I have an array containing multiple values that need to be serialized into ?id=val1&id=val2
. However, the problem arises when trying to set an optional route parameter as an array with multiple values such as ;id=val1&;id=val2
.
param['products'] = [];
param['products'].push(1);
this.router.navigate(['',param]) // This works fine
param['products'].push(2);
this.router.navigate(['',param]) // However, this does not work
I also attempted
this.router.navigate(['', [...param]])
but unfortunately, it did not work as expected.