I am getting endpoints from a file within my assets folder before the
angular app is bootstrapped. I get the endpoints alright but the app UI
doesn't display unless I reresh the page. The application works fine if I
do not tap into App_Initializer. Please I would need your help to fix it.
Below is my code
*AppModule
export function init_app(appLoaderService: AppLoaderService) {
return (): Promise<any> => {
return appLoaderService.getEndpoints();
}
}
@NgModule({
providers: [
AppLoaderService,
{
provide: APP_INITIALIZER,
useFactory: init_app,
deps: [AppLoaderService],
multi: true
}
],
*Service
getEndpoints(): Promise<any> {
const promise = this.client.get<EndPoints>('assets/apiEndPoints.json').
toPromise()
.then(data => {
this.endpoints = data;
console.log('Endpoints', data);
return data;
});
return promise;
}
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
To view this discussion on the web visit
https://groups.google.com/d/msgid/angular/1823dcd6-d1dd-4795-9ed8-50595aa89acd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.