Angular conditional provideRouter features

Discussão em 'Angular' iniciado por Mad Eddie, Fevereiro 20, 2025.

  1. Mad Eddie

    Mad Eddie Guest

    I have an Angular (18.2) + Electron (26) application which requires the HashLocation whereas when running on the web does not need this.

    Within the standard app.config.ts I simply use the below for Electron

    provideRouter: (routes, withHashLocation())


    How can I make this dynamic so that withHashLocation is not added when not Electron?

    The only way to check if the Angular site is running under Electron is with the below statement which feels like it isn't accessible when the app.config.ts is loaded.

    this.windowReference.api && this.windowReference.api.isElectron

    Continue reading...

Compartilhe esta Página