Skip to content

Instantly share code, notes, and snippets.

@adamtester
Created September 1, 2017 13:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamtester/163602e8f48c7978738af67449c3f66b to your computer and use it in GitHub Desktop.
Save adamtester/163602e8f48c7978738af67449c3f66b to your computer and use it in GitHub Desktop.
Angular 4 Hash URL on local, HTML5Mode on production
import { NgModule } from '@angular/core';
...
import { environment } from '../environments/environment';
@NgModule({
...
providers: [{
provide: LocationStrategy,
useClass: environment.production ? PathLocationStrategy : HashLocationStrategy,
}],
...
})
export class AppModule { }
@nimat-netlinks
Copy link

Do you have any solution to remove # from url ?

@nimatrazmjo
Copy link

I think It should be like useClass: environment.production? HashLocationStrategy: PathLocationStrategy. Because PathLocationStrategy does not work on production, and HashLocationStrategy does not work with navigate on local

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