Want to check if an array is empty in your templates, for example:
1 2 3 |
{{if hasNoComments}} <div>No comments</div> {{/if}} |
There are many ways to do this, one way would be check the array length e.g.
1 2 3 4 |
hasNoComments: Ember.computed('comments.length',() => { if(!this.get('comments')) return true; return this.get('comments.length') < 1; } |
Or even better, you can use the empty computed helper in your controller to easily check if your comments array is empty with:
1 |
hasNoComments: Ember.computed.empty('comments') |
Also published on Medium.