本文介绍了同一页面中的Angular 6路由器链接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
['/productlist',1000]
['/productlist',1001]
['/productlist',1000]
['/productlist',1001]
我有两个链接:
这两个链接在同一页面上.如果我是第一次单击任何链接.它正在重定向到页面,但是如果我单击其他链接,则该页面不起作用.
These two links are on the same page. If I click on any link for the first time. It is redirecting to the page, but if I click on the other link it is not working.
component.html代码
component.html code
<a class="dropdown-item" (click)="GetProductList(subitem.SubCategoryID)"> <i class="mdi mdi-chevron-right" aria-hidden="true"></i> {{ subitem.SubCategoryName}} </a> GetProductList(SubCategoryID){ this.router.navigate(['/productlist',SubCategoryID]); }推荐答案
由于角度,它是同一条路线-不会重新加载.
Since for angular it is same route - it is not reloaded.
两种可能的解决方案:
在组件中订阅this.route.params并做出相应的反应,例如在 Angular 4 routerLink-重新加载当前路由
在Angular 5中,有一个用于重新加载活动路径的选项:
in Angular 5 there is an option for reloading the active route:
RouterModule.forRoot(routes,{onSameUrlNavigation:'reload'}
RouterModule.forRoot(routes, {onSameUrlNavigation: ‘reload’}
尝试
更多推荐
同一页面中的Angular 6路由器链接问题
发布评论