双击后,带有[RouterLink]结果,可导航到默认路由的侧菜单项
我在Angular应用程序上的侧面菜单上解决了一些错误,当我两次单击侧面菜单项时,我总是将其重定向到默认路由。如下面的屏幕截图所示,当我单击财务年度
菜单项时,我将被重定向到付款帐户
路由。是什么可能导致这种行为?
我在Sidemenu项目上使用RouterLink
。
如下所示,我正在使用Routerlink
...
<div class="category-children" *ngIf="rlaAcc.isActive">
<!-- Section Bank Accounts -->
<div mat-list-item id="item-accounting-transfers" data-intercom-target="Accounting module transfers"
[routerLink]="['/accounting', property.id, 'transfers']" routerLinkActive="active-child"
#rlaAccBank="routerLinkActive" class="child-header">
</div>
<div class="category-children" *ngIf="rlaAccBank.isActive">
<div mat-list-item id="item-accounting-transfers" data-intercom-target="Accounting module transfers"
[routerLink]="['/accounting', property.id, 'transfers', 'currents']" routerLinkActive="active-sub-child"
class="child-header">
</div>
<div mat-list-item id="item-accounting-transfers" data-intercom-target="Accounting module transfers"
[routerLink]="['/accounting', property.id, 'transfers', 'savings']" routerLinkActive="active-sub-child"
class="child-header">
</div>
</div>
...
会计路线
export const ACCOUNTING_ROUTES: Route[] = [
....
// Default link
{
path: ':propId',
redirectTo: '/accounting/:propId/transfers/currents',
pathMatch: 'full', data:{propId:[`:propId`]},
canActivate: [IsOnboardedGuard]
},
{ path: ':propId/financial-years', loadChildren: () => import('@xyz/features/accounting/financial-years/main').then(m => m.FinancialYearsHomeModule), canActivate: [IsOnboardedGuard] },
......
];
财政年度路线
const FINANCIAL_YEAR_ROUTES: Routes = [
{ path: '', component: FinancialYearsHomePage,
children: [
{ path:'', redirectTo: 'overview', pathMatch: 'full'},
{ path: 'overview', component: FYearsOverviewPage }
],
},
];
路线日志我的测试环境
I'm resolving some bug on the side menu on an Angular application, when I click on the side menu item twice I'm always redirected to the default route. As shown from the screenshot below when I click on the Financial years
menu item I will be redirected to the Payment Account
route. What might be causing this behavior?
I'm using routerLink
on the sidemenu Items.
As you can see below I'm using routerLink
...
<div class="category-children" *ngIf="rlaAcc.isActive">
<!-- Section Bank Accounts -->
<div mat-list-item id="item-accounting-transfers" data-intercom-target="Accounting module transfers"
[routerLink]="['/accounting', property.id, 'transfers']" routerLinkActive="active-child"
#rlaAccBank="routerLinkActive" class="child-header">
</div>
<div class="category-children" *ngIf="rlaAccBank.isActive">
<div mat-list-item id="item-accounting-transfers" data-intercom-target="Accounting module transfers"
[routerLink]="['/accounting', property.id, 'transfers', 'currents']" routerLinkActive="active-sub-child"
class="child-header">
</div>
<div mat-list-item id="item-accounting-transfers" data-intercom-target="Accounting module transfers"
[routerLink]="['/accounting', property.id, 'transfers', 'savings']" routerLinkActive="active-sub-child"
class="child-header">
</div>
</div>
...
Accounting ROUTES
export const ACCOUNTING_ROUTES: Route[] = [
....
// Default link
{
path: ':propId',
redirectTo: '/accounting/:propId/transfers/currents',
pathMatch: 'full', data:{propId:[`:propId`]},
canActivate: [IsOnboardedGuard]
},
{ path: ':propId/financial-years', loadChildren: () => import('@xyz/features/accounting/financial-years/main').then(m => m.FinancialYearsHomeModule), canActivate: [IsOnboardedGuard] },
......
];
Financial Year ROUTES
const FINANCIAL_YEAR_ROUTES: Routes = [
{ path: '', component: FinancialYearsHomePage,
children: [
{ path:'', redirectTo: 'overview', pathMatch: 'full'},
{ path: 'overview', component: FYearsOverviewPage }
],
},
];
Route Logs from my test environment
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎问题是路由组件无法在同一URL上重新加载。为了在同一URL导航上重新加载组件,我将设置为onSameUrlNAvigation reload ,并提供 routereusestrategy false 在组件上均应false 。
Seems like the issue was the routed component could not reload on the same url. In order to reload routed components on same url navigation, I set onSameUrlNavigation to reload and provide a RouteReuseStrategy which returns false for shouldReuseRoute on the component.