"@angular/core": "^6.1.4"
Here is my .html:
<div *ngIf="errors$ | async as errors">
<div class="container alert alert-danger" *ngIf="errors.length > 0">
<b>{{errors.length}} error(s)</b>
<ul *ngFor="let error of errors">
<li>{{error}}</li>
</ul>
</div>
</div>
My question is: can I reduce it down to a single *ngIf
?
I have tried the following:
(errors$ | async as errors).length > 0
(errors$ | async as errors) && errors.length > 0
Both of these gave a template parse error.
I have already looked at How to check the length of an Observable array, this question is different because I want to use as
syntax.
All I want to do is subscribe to the observable with the as
syntax and only show this div if the length of the array is greater than 0. Any help would be appreciated!