In Angular 2 I would like to use the hash strategie only for IE9. For that I configure the router to use the hash strategy only if I detect the IE9 browser.
This was working when compiling with tsc:
const useHash: boolean = (typeof window.history.pushState) !== 'function';
@NgModule({
declarations: [AppComponent],
imports: [
RouterModule.forRoot(appRoutes, {initialNavigation : false, useHash : useHash})
]
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}
However the ngc compiler (AOT compilation) does not accept it. The following error is thrown by ngc (on the const declaration line).
Error encountered resolving symbol values statically. Expression form not supported
I have also tried (based on this article: https://medium.com/@isaacplmann/making-your-angular-2-library-statically-analyzable-for-aot-e1c6f3ebedd5#.h4pnszi13):
@NgModule({
declarations: [AppComponent],
imports: [
RouterModule.forRoot(appRoutes, {initialNavigation : false, useHash : AppModule.useHash})
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
static useHash: boolean = (typeof window.history.pushState) !== 'function';
}
But I get the same error (on the provider line this time). Note that it works if I do static useHash: boolean = false;
.
How can I solve the issue for the module declaration?