Can we have multiple <router-outlet> angular2 +?

If it is possible to have multiple routers, I do not have working code, but I assume that I have a login page for the parent <router-outlet> in the AppComponent . After logging in, I have to show MyHomeComponent in the parent <router-outlet> . Suppose in MyHomeComponent I need a <router-outlet> child element in which I want to display inbox messages, starred messages, starred messages when a user clicks on inbox , outbox and starred links. Please help me find the answer to this question.

AppComponent <router-outlet></router-outlet> ,

Homecompponent

 <a routerLink="/xyz">Inbox</a> <a routerLink="/abc">Outbox</a> <router-outlet name='outlet1'></router-outlet> 

My route routes

 { path: 'login', component: LoginComponent}, { path: '', component: LoginComponent }, { path: 'user', children:[ { path: ':name',children:[ {path:'abc', component: InboxComponent, outlet: 'outlet1' }, {path:'xyz', component: OutboxComponent, outlet:'outlet1' } ] }]}, { path: '**', component: PageNotFoundComponent } 
+6
source share
1 answer

You can have one primary <router-outlet> for each route and an additional one with the name <router-outlet name="abc"> s. The routes addressed to these named outputs are called auxiliary routes. These routes are reflected in the URL in () as /crisis-center(aux:chat;open=true)"

see also

+6
source

All Articles