How can I successfully pass a string value along with navigation from one component to another using query parameters?
Component1:
stringData = "Hello";
this.router.navigate(['component2'], { queryParams: stringData });
Component2:
ngOnInit() {
this.route.queryParams.subscribe(params => {
console.log(params)
})
}
The console output I get in component2 is:-
{
"0": "H",
"1": "E",
"2": "L",
"3": "L",
"4": "O",
}
In the browser after navigation, I can see
domain.com/child20=H&1=E&2=L&3=L&4=O. Why is it not passing as a complete string?