Angularにおけるルートの順序
Angularはルートを上から下に処理します。 これは、より具体的なルートを最初に配置し、 その後により一般的なルートを配置する必要があることを意味します。
次の例では、常に最初のルートが発火します:
const appRoutes: Routes =[
{ path: '**', component: NotFoundComponent },
{ path: 'aaaa', component: AaaaComponent},
{ path: 'bbbb', component: BbbbComponent},
];
例のルートの順序を正しい順序に変更してください:
const appRoutes: Routes =[
{ path: 'blog/:id', component: AaaaComponent},
{ path: 'blog/new', component: BbbbComponent},
];