I am using a div with an ngIf like following:
<div class="..." *ngIf="list; else loading">
....
</div>
<ng-template #loading>
....
</ng-template>
everything is working fine. The list is updated in the component after my service returns with data.. The only problem is, the DOM is only being updated, after the user clicks or scrolls. Otherwise the Loading Template is staying...
Im using the same construct in other parts of my project. It's working fine there.. Anybody knows why this is happening and how to resolve this?
Update:
At first i was using the ngIf with an async pipe
<div class="..." *ngIf="listObs | asnyc; else loading">
....
</div>
Right now im subscribing manually in the component
this.subscriptions.add(this.dataService.listObs.subscribe((list: Array<any>) => {
this.list = list;
}
Both ways end in the same result. DOM is only being updated after user interaction. Adding this.changeDetectorRef.detectChanges();
in the manual subscription "solves" the problem.