angular routting pass data code example
Example: pass data in route angular
// Send user data
let navigationExtras: NavigationExtras = {
state: {
user: this.user
}
this.router.navigate(['details'], navigationExtras);
// Acess data in details page
....
constructor(private route: ActivatedRoute, private router: Router) {
this.route.queryParams.subscribe(params => {
if (this.router.getCurrentNavigation().extras.state) {
this.data = this.router.getCurrentNavigation().extras.state.user;
}
});
}
}
.....