<router-outlet name="some_name"></router-outlet>
& the routes goes as {path: '', component: SomeComponent}
TS无法识别它。
'name' doesn't exists in route
如何在新版本中实现它。!
答案 0 :(得分:1)
我相信你想使用 named-router-outlet
eg. <router-outlet name="some_name"></router-outlet>
为此,您可以使用名为outlet
的新属性和路由,如下所示
{ path: '', redirectTo: 'home', pathMatch: 'full'},
{ path: 'home', component: HomeComponent},
{path: '', component: DetailComponent, outlet: 'details'} //<<<===Check here
这条路线说,每当我运行我的应用程序时,我想在普通路由器中注入 HomeView ,但在 DetailView >命名路由器出口即可。在组件中一起使用,例如,
@Component({
selector:"my-app",
template:`
<h3>Normal router-outlet</h3>
<router-outlet></router-outlet>
<hr>
<h3> Router-outlet with name attribute</h3>
<router-outlet name='details'></router-outlet>
`
})
export class AppComponent{
}