How to access the value provided by the route model hook inside the main template
By default, inside the setupController route hook, Ember will set the model property on your controller to the allowed value of the promise returned from the route model hook.
Meaning, you can use the model property in a template to access model.navigation :
<nav> {{#each model.navigation as |navItem|}} <li>{{#link-to navItem.link}} {{navItem.title}} {{/link-to}}</li> {{/each}} </nav>
If you want to use a different name, you can override the setupController hook and set the name yourself:
export default Ember.Route.extend({ // ... setupController(controller, model) { this.set('navigation', Ember.get(model, 'navigation')); } // ... rest of the code })
This means that now you can use navigation instead of model.navigation inside the template. Another way is to add alias to your controller for the model property:
export default Ember.Controller.extend({ navigation: Ember.computed.alias('model.navigation') // ... rest of the code })
This will allow you to use navigation instead of model.navigation .
However, if you want to have some kind of global navigation in your application, the best way would be to use the Service that you enter into any controller that needs navigation. Sort of:
// app/services/navigation.js export default Ember.Service.extend({ items: null, init() { this._super(...arguments); this.set('items', [{ title: "Projects", link: "projects" }, { title: "My Specifications", link: "specs" }]); } });
And then enter it into your controllers:
export default Ember.Controller.extend({ navigation: Ember.service.inject() });
You now have access to navigation in this controller template.