pass data through router 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;
}
});
}
}
.....
0
0
this.router.navigate(["heroes"], {some-data: "othrData"})
Thank you!
0
0
Are there any code examples left?
New code examples in category TypeScript