I try to set the APP_BASE_HREF in the "CoreModule" with a value from a async rest call. I can't see how this is done, because the provide method needs to return a string.
for example:
@NgModule({
imports: [
...
HttpModule
],
...
providers: [
...
...
BackendRequestClass,
{ provide: APP_BASE_HREF, useFactory: () => () => return '/some/path', deps: [], multi: true }
],
});
but when I need the value from a webservice, I can't return the string. Any ideas how this could be done?
thx
You can use
APP_INITIALIZERto get the path in advance and then use a dependency as shown in Angularjs2 - preload server configuration before the application startsThe
ConfigServicecan injectBackendRequestClassorHttpand fetch the data and then make it available using itsappBaseHrefproperty (just an example how it could be done).