I am sending data through routing like this
navigateWithState(x) {
console.log(x);
this.router.navigateByUrl('/full-layout/add-form/1', { queryParams: {x} });
}
And fetching it like this
constructor(private route:ActivatedRoutet) {
if(this.options == 1){
console.log('edit');
this.route
.queryParams
.subscribe(params => {
console.log(params);
});
}
else{
console.log('add');
}
}
but don't know why it is showing an empty array
You can see in the console
In console value, x has data that is showing in the console but when I pass through router it's showing blank.
I also try with navigationExtras like this
navigateWithState(x) {
console.log(x);
const queryParams: any = {};
queryParams.myArray = JSON.stringify(x);
const navigationExtras: NavigationExtras = {
queryParams
};
this.router.navigateByUrl('/full-layout/add-form/1', navigationExtras);
}
in .ts
if(this.options == 1){
console.log('edit');
const myArray = this.route.snapshot.queryParamMap.get('myArray');
console.log(myArray);
}
else{
console.log('add');
}
It's showing null in myArray.
