I am observing what looks like an inconsistent format when reading ActivatedRoute params.
- when the component is first reached with an array of parameters in the url (
localhost:1/a;t=1,2),params['t']comes out as a string:'1,2' - when navigating programmatically via the router later, the same kind of url is produced (
localhost:1/a;t=1,2), but nowparams['t']is an array of numbers[1, 2]
In both cases the params are obtained via the same subscription, done at init:
constructor(private router: Router, private route: ActivatedRoute) {}
ngOnInit() {
this.route.params.subscribe((params: Params) => {
console.info(JSON.stringify(params)),
});
}
// if needs be, here's how I perform the programmatic navigation
this.router.navigate(['.', {t:[1,2]}], {relativeTo: this.route})
Of course I can check the type of the params I get and convert before using, but it seems a bit ugly. Is this something known or am I missing something ?