How to check empty object in angular 2 template using *ngIf

前端 未结 7 1212
逝去的感伤
逝去的感伤 2020-12-04 16:26

I want to check if my object is empty dont render my element, and this is my code:


      
7条回答
  •  独厮守ぢ
    2020-12-04 17:10

    You could also use something like that:

    with the isEmptyObject method defined in your component:

    isEmptyObject(obj) {
      return (obj && (Object.keys(obj).length === 0));
    }
    

提交回复
热议问题