nativescript angular dynamic navigation
//in the app-routing.module.ts
const routes: Routes = [
{ path: "", component: HomeComponent },
{ path: "path1", component: OtherComponent },
{ path: "path2",
children: [
{ path: ":data", component: AnotherComponent }
]
}
]
//then you can pass anything in the component.html like this:
<Button text="Pass data" nsRouterLink="/path2/<your-data>"></Button>
//and get it like this in the another-component.ts:
constructor(private activatedRoute: ActivatedRoute) { }
ngOnInit(): void {
this.pageRoute.activatedRoute.subscribe(
activatedRoute => {
activatedRoute.paramMap.subscribe(
paramMap => {
this.data = paramMap.get('data');
},
err => console.log(err)
);
}
);
}
);
}