角度のある2つの親ルートのレバーにアクセスする方法を知りたいです。例:次のルートを使用する場合、AttributeListComponentでcomponentIdを取得するにはどうすればよいですか。
const routes: Routes = [
{path: '', redirectTo: '/components', pathMatch: 'full'},
{path: 'components', component: SideNavComponent,
children: [
{path: ':componentId', component: ComponentTabComponent, children: [
{path: '', redirectTo: 'entities', pathMatch: 'full'},
{path: 'entities', component: EntityListComponent, children: [
{path: ':entityId', component: EntityTabComponent,
children: [
{path: '', redirectTo: 'attributes', pathMatch: 'full'},
{path: 'attributes', component: AttributeListComponent},
{path: 'tasks', component: TaskListComponent}
]}
]},
{path: 'domains', component: DomainListComponent}
]},
]},
{ path: '**', component: PageNotFoundComponent }
];
parent
プロパティを使用してルーターツリーをトラバースできます。例:
constructor(private route: ActivatedRoute) {}
...
this.route.parent.parent.parent.queryParams.subscribe(...
parent
自分で必要な数を計算します:)。これはchildren
、ルートファイルにある数に基づいています。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加