我已經配置我的路由是這樣的:角2兒童路線
const routes: Routes = [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: 'dashboard', component: HomeComponent },
{
path: 'contact', component: ContactComponent,
children: [
{
path: '',
component: ContactComponent
},
{
path: 'list',
component: ContactlistComponent
},
]
},
// { path: 'list', component: ContactlistComponent },
{ path: 'configuration/forms', component: FormsComponent }
];
這裏是我的鏈接:
<a [routerLink]="/contact/list">List</a>
<a [routerLink]="/contact">Add New</a>
所以,當我點擊這兩個鏈接我的聯繫紐帶越來越開放。
這裏,當我這樣做它的工作原理:
const routes: Routes = [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: 'dashboard', component: HomeComponent },
{
path: 'contact', component: ContactComponent,
},
{ path: 'contact/list', component: ContactlistComponent },
{ path: 'configuration/forms', component: FormsComponent }
];
什麼,我做錯了什麼?
它的工作與代碼的微小變化。我在我的問題中更新了這個答案中的代碼。它沒有工作,因爲我已經給出了父組件,這就是爲什麼它把我帶到那個默認的聯繫組件。 –