How to show message for an empty model instead of loading in hbs template, each or if


I use very often in my code (and I don’t know if I’m right to use it):

{{#each model.posts as |post|}}



  <div>I'm loading the posts...</div>


and until today everything OK.

But now I don’t know if the model.posts is empty or not.

How to show an error instead of loading forever an empty array?


Which version of Ember do you use? In the API docs, the behaviour of the {{each}}-Helper is just described as you say Ember API Docs - Ember.Templates.helpers


Yes but the problem is not the {{each}}.


oh, ok. I’m sorry but I thought that the {{else}} is what doesn’t happen and therefore you don’t know if the array is empty or not…? I’m no native speaker so sorry if I got you wrong :slight_smile:


I’m using the isPending property on a hasMany model like this:

{{#if model.posts.isPending}}
  <div>I'm loading the posts...</div>
  {{#each model.posts as |post|}}
    <div>There are no posts</div>


There is a problem with this code, how to solve? See: