nativescript angular dynamic navigation

Solutions on MaxInterview for nativescript angular dynamic navigation by the best coders in the world

showing results for - "nativescript angular dynamic navigation"
Arianna
02 Feb 2016
1//in the app-routing.module.ts
2const routes: Routes = [
3    { path: "", component: HomeComponent },
4    { path: "path1", component: OtherComponent },
5    { path: "path2",
6        children: [
7            { path: ":data", component: AnotherComponent }
8        ]
9    }
10 ]
11//then you can pass anything in the component.html like this:
12<Button text="Pass data" nsRouterLink="/path2/<your-data>"></Button>
13//and get it like this in the another-component.ts:
14constructor(private activatedRoute: ActivatedRoute) { }
15ngOnInit(): void {
16      this.pageRoute.activatedRoute.subscribe(
17          activatedRoute => {
18              activatedRoute.paramMap.subscribe(
19                  paramMap => {
20                      this.data = paramMap.get('data');
21                        },
22                        err => console.log(err)
23                    );
24                  }
25              );
26          }
27      );
28}