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

编程入门 行业动态 更新时间:2024-10-26 08:33:17
本文介绍了同一页面中的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路由器链接问题

    本文发布于:2023-11-16 19:59:46,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1607253.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:路由器   页面   链接   Angular

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!