79590056

Date: 2025-04-24 07:50:49
Score: 2
Natty:
Report link
  Length: {{ (list$ | async)?.length }}
  @if((list$ | async)?.length > 0){
  <ul>
    <li *ngFor="let item of (list$ | async)">
      {{ item.name }}
    </li>
  </ul>
  }@else {
    <span>no data</span>
  }

I use Angular 17, and this solution worked perfectly for me. To check the length of an observable array and handle empty data, I use the async pipe with the safe navigation operator ?.

Reasons:
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: azizkale