Answers for "pass data in route angular"

0

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;
      	}
    	});
  	}
}
.....
Posted by: Guest on March-03-2021
1

pass data through router angular

this.router.navigate(["heroes"], {some-data: "othrData"})
Posted by: Guest on March-22-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language