PathMatch full 始终连接到参数化路径,即使完整路径不匹配

问题描述 投票:0回答:1

我有这样的路线

{
    path: ':fundHouseName',
    pathMatch: 'full',
    children: [{
        path: RoutePaths.funds,
        component: FundsComponent,
        canActivate: [AuthGuard]
    }]
},
{
    path: '',
    children: [{
        path: RoutePaths.funds,
        component: FundsComponent,
        canActivate: [AuthGuard]
    }]
},

我想要的是这条路由应该与参数化路由(第一条路由)匹配

https://localhost:4200/Kotak/funds

这应该与非参数化的(第二条路线)匹配

https://localhost:4200/funds

但是两条路线都与参数一匹配,而我在参数路线上放置了

pathMatch:'full'
,所以我的理解是,在路线已满之前,它不应该与参数路线匹配,也就是说,路线应该有
:fundHouseName
部分然后
funds
部分,所以基本上路径必须是像这样的完整路径

XYZ/funds

我对

pathMatch
的理解有误吗?

我怎样才能实现这种行为?

angular angular-routing
1个回答
0
投票

只需交换顺序即可解决问题。

Angular 路由器将始终匹配第一个可能的值,因此您需要构建列表值,以便为所有可能的场景匹配正确的值

© www.soinside.com 2019 - 2024. All rights reserved.