Angular2 *ngIf check object array length in template

后端 未结 5 652
北恋
北恋 2020-12-12 23:43

Refered to https://angular.io/docs/ts/latest/guide/displaying-data.html and stack How to check empty object in angular 2 template using *ngIf still getting syntax error self

5条回答
  •  长情又很酷
    2020-12-13 00:08

    You can use

    Without event.attendees?.length > 0 or even event.attendees?length != 0

    Because ?.length already return boolean value.

    If in array will be something it will display it else not.

提交回复
热议问题