1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Why is ion-back-button always using the defaultHref

Discussão em 'Angular' iniciado por Schnitzler, Maio 19, 2025.

  1. Schnitzler

    Schnitzler Guest

    Why is the ion-back-button always using the defaultHref when navigating from the root to a /:id route?

    Here's my route setup

    import { Routes } from '@angular/router';

    export const routes: Routes = [
    { path: '', loadComponent: () => import('./components/home/home.component').then(c => c.HomeComponent) },
    { path: ':id', loadComponent: () => import('./components/entity/entity-read/entity-read.component').then(c => c.EntityReadComponent) },
    ];


    My ion-router-outlet is inside the AppComponent (root component)

    <ion-app>
    <ion-router-outlet />
    <app-tabs />
    </ion-app>


    The root page (HomeComponent) always has a query string so we can show data to the user.

    However, when navigating from HomeComopnent to the /:id page, Ionic doesn't seem to add that page to the stack - there is no forward-navigation animation. In addition, the NavController.navigateForward('url') method doesn't fix it.

    After navigating to the /:id route, the ion-back-button always goes back to the defaultHref, and when I remove the defaultHref, the ion-back-button isn't there at all.

    I know I am missing something here, because this is working in all other pages in my application.

    Continue reading...

Compartilhe esta Página