同一页面中的 Angular 6 路由器链接问题 [英] Angular 6 router link issue in the same page
本文介绍了同一页面中的 Angular 6 路由器链接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个链接:
['/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]);
}
推荐答案
由于 angular 它是相同的路线 - 它不会重新加载.
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 路由器链接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文