locked
when make routing using router Link it create url correct but not redirect to component and display data? RRS feed

  • Question

  • User696604810 posted

    I work on angular 7 app I face issue when route to component report details

    using router link it only create URL link on browser but not redirect to

    component report details until I click Enter.

    It only working routing correctly if I use href .

    If I use href or router link two both generate same URL link

    http://localhost:4200/reportdetails?id=2028

    If I use router Link I write router link as :

    <a [routerLink]="['/reportdetails']" [queryParams]="{id: subrep.reportID}" >

    When use href I write as below :

    <a href="/reportdetails?id={{subrep.reportID}}">

    approutingmodule.ts :

    const routes: Routes = [
      {path:'',redirectTo: 'ReportCategoryComponent', pathMatch: 'full'},
      {path:'report',component:ReportCategoryComponent},
      {path:'reportdetails',component:ReportdetailsComponent},
      {path:'reportdetails/:id',component:ReportdetailsComponent}
    ];

    so How to solve of issue of router link redirect ?

    Saturday, May 23, 2020 3:19 AM

All replies

  • User-474980206 posted

    Typically client routing does not include the query string, it’s passed as a parameter to the selected component. The exception is when the the parameter is part of the path, not the query string. It looks like angular uses the common syntax

        path:'reportdetails/:id’,   //ex  reportdetails/25
    Saturday, May 23, 2020 5:28 PM
  • User696604810 posted

    thank you for reply

    so what i change or what i do to solve issue

    Saturday, May 23, 2020 10:00 PM