Angular 6路由器链接问题在同一页面

标签 angular angular6 angular-components

我有两个链接:

  1. ['/productlist',1000]
  2. ['/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 来说,它是相同的路线 - 它不会重新加载。

两种可能的解决方案:

  1. 在组件中订阅 this.route.params 并做出相应的 react ,就像 Angular 4 routerLink - reloading current route 中那样

  2. 在 Angular 5 中,有一个用于重新加载事件路由的选项:

RouterModule.forRoot(routes, {onSameUrlNavigation: ‘重新加载’}

尝试一下

关于Angular 6路由器链接问题在同一页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52854256/

相关文章:

angular - 如何创建带有 Angular 键/值对的字典?

angular-cli - npm WARN tar EPERM : operation not permitted, 打开

typescript - Angular 5 - 刷新组件(不是整个页面)

AngularJS 1.5 - 如何在组件上设置两种方式绑定(bind)

html - 具有自定义宽度的 PrimeNG TurboTable 无法正常工作

javascript - RxJs:使用 async/await 共享 Observable

html - Bootstrap 4 图像 slider 添加表单不能做小尺寸和居中

angular - 如何在 Chrome 开发工具中源映射 Angular CLI css 文件?

css - 在组件中使用 CSS 动画显示和隐藏

javascript - Angular 4 FormGroup - 将父表单控件传递给子组件