1
urlに特定の値だけがある場合、特定のコンポーネントを表示する方法を見つけようとしています。 は、基本的にこれが今のルーティングを探している方法です。特定の値に一致するAngular2ルート
const routes: Routes = [
{
path: 'users',
component: MainComponent,
children: [
{
path: ':id',
component: DashboardComponent,
children: [
{
path: '1',
component: NeedToRenderThisComponent
},
{
path: '',
component: DashboardComponent
},
{
path: '',
outlet: 'sidebar',
component: SidebarComponent
}
]
}
]
}
];
それでは、私が探していますがときに、ユーザーのヒットであるか「/ユーザー/ 1」に別の道に入り、ユーザーがNeedToRenderThisComponentが表示されます。他のすべての値にはDashboardComponentがあります。
DashboardComponentは2つのルータアウトレット
<router-outlet name="sidebar"></router-outlet>
<router-outlet></router-outlet>
そこで、基本的thissがすべてを一致するとコンポーネントをレンダリングします、その後、コンポーネントで、私は次回のアップデートで利用できるようになりますURLに基づいて動的にコンポーネントをレンダリングする、そうですか? – user2732627
まあ、それは私の考えでした。 –
カスタムパスの一致がサポートされているようです。私の更新された答えを見てください。 –