我覺得真的很難作出一個子子路徑參數工作角2 - PARAM缺失分次路線
這些第一2級做工精細
http://localhost:8080/#/customer/4/
http://localhost:8080/#/customer/4/campaign/13
http://localhost:8080/#/customer/4/campaign/13/segments
,但一旦我嘗試這一個
http://localhost:8080/#/customer/4/campaign/13/segment/1
第三個參數/ 1未填充,所以我不能使用它
this.activatedRoute.parent.params.subscribe((params: any) => {
let customerId = +params['id']; <<< present
let campaignId = +params['cid']; <<< present
let segmentId = +params['sid']; <<< NaN !!!!
....
});
這裏是我的路由設置
const customersRoutes: Routes = [
{ path: 'customer/:id',
canActivate: [AuthGuardService],
children: [
{ path: '', component: CustomerComponent },
{ path: 'campaign/:cid', component: CustomerCampaignComponent ,
children:[
{ path: 'segments', component: SegmentsComponent },
{ path: 'segment/:sid', component: SegmentComponent },
]
},
]
}
];
任何人都知道我怎麼能解決這個問題?
感謝
如果您手動鍵入的URL第三個參數,它的工作與否? –
它正確的路由,但最後的ID永遠不會進入params數組 – phil1234