I have an angular application uses routing with HashLocationStrategy, I need to set different value in main html file and different in routing.
I tried this solution:
@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpModule,
MyRouting // with useHash set to true
],
declarations: [
AppComponent,
],
providers: [
{ provide: APP_BASE_HREF, useValue: '/prefix' }
],
bootstrap: [AppComponent]
})
export class AppModule { }
Works almost well but value '/prefix' is insert after hash, like this:
http://myapp.com/#/prefix/home
Whereas i want:
http://myapp.com/prefix/#/home
For clarity, my base tag is:
<base href="/">
yahoooooooooooo !! got it to work.
in your index.html file, specify the baseurl as "." like this:
and specify the hash location strategy in your
providers
property in yourNgModule
decorator in yourapp.module.ts
, like this:see: https://github.com/datumgeek/plotter-app-seed-angular2/blob/master/src/app/app.module.ts#L26
running demo here: https://datumgeek.github.io/plotter-app-seed-angular2/#/shell;stateRepositoryId=file-host-01;sessionId=session-03
I came across the same problem and fixed it with my own Subclass of HashLocationStrategy
Then just using it in my module