This seems like it would be simple but I cannot find anything to address it. What I'm trying to do is to have a CSS spinner/loader while an asynchronous list loads. I've tried all kinds of things including trying to use ngSwitch, but so far nothing works and the spinner just spins indefinitely. Here is the base code:
<div class="col-md-2 mediaContainer">
Media:
<ul class="media">
<li *ngFor="let medium of media | async"
[class.selected] = "medium === selectedMedium"
(click)="onSelect(medium)">
{{medium.name}}
</li>
</ul>
</div>
While I've tried lots of things the following is an example that will not work:
<div class="col-md-2 mediaContainer">
Media:
<ul class="media" [ngSwitch]="status">
<li *ngSwitchCase="loading"><loaders-css [loader]="'square-spin'" [loaderClass]="'my-loader'"></loaders-css></li>
<li *ngFor="let medium of media | async"
[class.selected] = "medium === selectedMedium"
(click)="onSelect(medium)">
{{medium.name}}
</li>
</ul>
</div>
I've also put the ngSwitch and/or the switch cases inside the list but that doesn't work either. I have a feeling that 'status' only works with the elements themselves not their content, but I'm not sure how to set a switch value either (ie https://angular.io/docs/ts/latest/api/common/index/NgSwitch-directive.html) and this seems like something to do with a promise possibly. Any ideas? Given the nature of what I'm doing it seems like it would be pretty common...