I want to pass the data through router in Angular 4.
I am passing data from following function
onEdit(event)
{
console.log(event.data);
this.router.navigate(['pages/details'],event.data);
}
And I am receiving it like follows:
export class DetailsComponent {
data : any;
constructor(private route: ActivatedRoute) {
this.route.params.subscribe(params => {
this.data = params;
console.log(params);
});
console.log(this.data);
}
}
But its not giving me the data I have passed. Any help?