In my Angular 12 app I am using splash screen as div inside app-root.
<app-root>
<div class="splash-screen">
</div>
</app-root>
In router module forRoot path I am calling service to resolve data before display main component.
RouterModule.forRoot([
{
path: '', component: AppMainComponent,
resolve: {userInfo: userInfoResolver},
In my main component I am using that data
ngOnInit() {
this.route.data.subscribe(
(data: Data) => {
this.userInfo=data['userInfo'];
}
);
}
Service which fetching user Info running for few seconds, in that time splash screen is already gone and page is white without content.
My question is: How I can hide splash screen after fetching userInfo in ngOnInit method ? Where did I make mistake in defining splash screen or in way I prepare data for main component in resolve ?