I'm working with my application.hbs
template in EmberJS, and working to create a dynamic dropdown menu that is populated by the model contents. My route/model is defined like:
export default Ember.Route.extend({
model() {
return Ember.RSVP.hash({
dictionaries: ['One', 'Two', 'Three'],
test: 'Value'
});
}
});
And in my template, if I use {{model.test}}
, then it prints "Value"
successfully. However: When I try to build a list using the values of model.dictionaries
, both attempts fail, albeit differently.
This method:
{{#each model.dictionaries}}
<li><a href="#">{{this}}</a></li>
{{else}}
<li><a href="#" style="font-style: italic;">No values</a></li>
{{/each}}
Builds a list with 3 entries, but their contents are:
<li><a href="#">(generated application controller)</a></li>
<li><a href="#">(generated application controller)</a></li>
<li><a href="#">(generated application controller)</a></li>
And if I try instead to assign each item a name:
{{#each dict in model.dictionaries}}
<li><a href="#">{{dict}}</a></li>
{{else}}
<li><a href="#" style="font-style: italic;">No values</a></li>
{{/each}}
Then no values are displayed, resulting in:
<li><a href="#" style="font-style: italic;">No values</a></li>
What mistake am I making in attempting to iterate the model-provided array?
Aucun commentaire:
Enregistrer un commentaire