I have the following observable on and Angular component:
count$: Observable<number>;
this.count$ = this.getCount();
By using the following I get the value 0 (Zero);
this.count$.subscribe(x => console.log(x));
On the template I have:
<a routerLink="/dash" *ngIf="(count$ | async)">
  <ng-container *ngIf="count$ | async as count">
    Count: {{count}}
  </ng-container>
</a> 
If count$ is 1 I get Count: 1 but if count$ is 0 the content Count: 0 is not even rendered.
Any idea why?
In case anyone is looking for a workaround, this so stupid but it works:
   <ng-container *ngIf="{ len: count$ | async } as ctx">
      <ng-container *ngIf="ctx.len !== null"        
          {{ ctx.len }} 
       </ng-container>
   </ng-container>
Explanation:
count as len inside of an object called ctx*ngIf is now looking at an object, instead of the value, it will evaluate as truthy and render the ng-containerctx.len !== nullctx.lenIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With