Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does angular2 support nested states/routes?

Does angular2 support nested states/routes? for example in a view port there are 2 links and on clicking a specific link it will present a view which with further have more than one link but that are specific to earlier link.

like image 750
Suresh Reddy Guntaka Avatar asked Jan 24 '16 16:01

Suresh Reddy Guntaka


People also ask

Can also be used to traverse the router State?

ActivatedRouteSnapshot can also be used to traverse the router state tree.

What would you use in angular 2 to define route?

Instead of “href” attribute of anchor tag, we use the “routerLink” attribute of Angular. The routerLink attribute allows us to link to a specific route of the Application.


1 Answers

With the new version of the router, If you want to use nested routes, here is an example on how to define the path

{     path: 'search',     component: SearchComponent,     children: [         { path: 'results/:id',  component: ResultsComponent },     ] } 

and in your SearchComponent template, add <router-outlet></router-outlet>

like image 82
ThomasP1988 Avatar answered Oct 04 '22 12:10

ThomasP1988