Reputation: 11206
I have a helper method that takes one of my hashes and creates an array out of the keys:
signup-services-array.js
import Ember from 'ember';
export default Ember.Helper.helper(function(params) {
var serviceSignups = [];
var hash = params[0];
Object.keys(hash).forEach(function(key) {
serviceSignups.push(key);
});
return serviceSignups;
});
In my handlebar view, if I call {{signup-services-array model.signedServices}}
, I see the output caviar,doordash,lyft
.
However, if I try to iterate over it, I don't see anything:
<ul>
{{#each signup-services-array model.signedServices as |service|}}
<li>{{service}}</li>
{{/each}}
</ul>
How do I loop over the array in handlebar?
Upvotes: 1
Views: 31
Reputation: 18672
Try to wrap your helper in ()
:
<ul>
{{#each (signup-services-array model.signedServices) as |service|}}
<li>{{service}}</li>
{{/each}}
</ul>
Upvotes: 1