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>post.title</div>

{{else}}

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

{{/each}}

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>
{{else}}
  {{#each model.posts as |post|}}
    <div>{{post.title}}</div>
  {{else}}
    <div>There are no posts</div>
  {{/each}}
{{/if}}

There is a problem with this code, how to solve? See: javascript - Blink from loading (isPending) to resolved. Why? - Stack Overflow