In Handlebars, we could iterate over an object with key/value pairs. In HTMLbars I get the error Uncaught Error: Assertion Failed: The value that #each loops over must be an Array. You passed {prop1: prop1Value, prop2: prop2Valuel}
By design or bug?
This wasn't ever possible in Ember Handlebars/HTMLbars, by design, I believe it's related to the ability to observe the properties properly, but I could be lying about that.
From http://handlebarsjs.com/builtin_helpers.html {{each}} section:
When looping through items in each, you can optionally reference the current loop index via {{@index}}
{{#each array}}
{{@index}}: {{this}}
{{/each}}
Additionally for object iteration, {{@key}} references the current key name:
{{#each object}}
{{@key}}: {{this}}
{{/each}}
Yeah, I'm aware it exists in Handlebars by itself, but Ember Handlebars each helper != Handlebars each helper
You can do this via a custom component see example, but @kingpin2k is correct: this is not supported by our default {{each}} helper (and that is intentional).
It will be fairly trivial to implement once glimmer has landed, since we will be relying on diffing instead of enumerable observation.
Hello,
could this be what you're looking for?
http://handlebarsjs.com/builtin_helpers.html#with
each-in (api docs) was added to Ember. It was released in Ember 2.1
Most helpful comment
each-in(api docs) was added to Ember. It was released in Ember 2.1