Home > Back-end >  Why angular router reload page with routerLink directive?
Why angular router reload page with routerLink directive?

Time:07-23

I did a migration from Angular 10 to 13 and Ionic 5 to 6.

With my current set-up (Angular 13, Ionic 6), I have a strange behavior: when I navigate to new page using routerLink directive, the new page reload and the page stack is lose.

The behavior is the same as user typing directly the URL in navigator bar.

I tried to find similar issue or way to understand this behavior but nothing.

Can you help me please ?

Router Root configuration:

    RouterModule.forRoot(routes, {
      preloadingStrategy: PreloadAllModules,
      anchorScrolling: 'enabled',
      enableTracing: false,
      relativeLinkResolution: 'legacy'
    })

Link button integration:

<ion-button [routerLink]="['/dashboard/targets']" [queryParams]="{s: 'community'}" ...>...</ion-button>

Router Child configuration:

    RouterModule.forChild([
      {
        path: 'targets',
        loadChildren: () => import('./targets/targets.module').then( m => m.DashboardTargetsPageModule)
      }
    ]),

CodePudding user response:

There is a bug in Ionic 6, it was resolved in Ionic 6.0.16, try install that version.

npm install @ionic/[email protected]
  • Related