Skip to content

Instantly share code, notes, and snippets.

@killerchip
Last active January 6, 2018 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killerchip/e8698a92d100d23c4f540db0dff8ef20 to your computer and use it in GitHub Desktop.
Save killerchip/e8698a92d100d23c4f540db0dff8ef20 to your computer and use it in GitHub Desktop.
Angular cheatsheet - switching angular routing from default (HTML5 routing) to Hash based routing

Switching to Hash-based routing

By default Angular is using HTML5 routing (like https://shop.example.com/products/ab34e). If you wish you can switch easliy switch to Hash based routing (https://shop.example.com/#/products/ab34e).

in app.module.ts

import { LocationStrategy, HashLocationStrategy } from '@angular/common';

@NgModule ({
  ...
  providers: [
    { provide: LocationStrategy, useClass: HashLocationStrategy }
  ]
  ...
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment