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

How to enable hash routing with provideRouter in Angular?

Discussão em 'Angular' iniciado por Rens Jaspers, Julho 13, 2025.

  1. Rens Jaspers

    Rens Jaspers Guest

    How can I use hash routing with provideRouter from @angular/router in my Angular application?

    Previously, I was using useHash: true with RouterModule.forRoot() to enable hash-based routing like /#/page1 or /#/page2. Now I'm using provideRouter and I can't find a way to enable hash routing.

    This is my current setup:

    # main.ts
    import { bootstrapApplication } from '@angular/platform-browser';
    import { provideRouter } from '@angular/router';
    import { routes } from './app/app.routes';
    import { AppComponent } from './app/app.component';

    bootstrapApplication(AppComponent, {
    providers: [
    importProvidersFrom(IonicModule.forRoot({})),
    provideRouter(routes),
    ],
    });

    Continue reading...

Compartilhe esta Página