I'm trying to build my app's navigation dynamically based on model data.
In my application
template, I'm including a view for the navigation:
<div class="container">
<h1>My App</h1>
{{view App.NavView}}
</div>
Here's App.NavView
:
App.NavView = Ember.View.extend({
templateName: 'nav'
});
And the nav
template:
<ul class="nav">
{{#each contentTypes}}
<li><a href="#">{{name}}</a></li>
{{/each}}
</ul>
As you can see, I want to loop over contentTypes
and display the name
of each. Getting these Ember Data models is simple:
App.ContentType.find()
But where do I put this call so that my NavView
/nav
template has access to the array of models? Should NavView
make the call? Or do I make them available to the application template? How?
Thanks for your help!