我有两个链接:
['/productlist',1000]
['/productlist',1001]
这两个链接位于同一页面上。如果我第一次点击任何链接。它正在重定向到该页面,但如果我单击其他链接,它就不起作用。
component.html代码
<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 来说,它是相同的路线 - 它不会重新加载。
两种可能的解决方案:
在组件中订阅 this.route.params 并做出相应的 react ,就像 Angular 4 routerLink - reloading current route 中那样
在 Angular 5 中,有一个用于重新加载事件路由的选项:
RouterModule.forRoot(routes, {onSameUrlNavigation: ‘重新加载’}
尝试一下
关于Angular 6路由器链接问题在同一页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52854256/