It makes code more readable if model has the same name as a subject. It’s more maintainable, and will conform to future routable components. We can do this in two ways:
- set alias to model (in case when there is a
Nail Controller
):
const { alias } = Ember.computed;
export default Ember.Controller.extend({
nail: alias('model'),
});
- set it in
setupController
method:
export default Ember.Route.extend({
setupController(controller, model) {
controller.set('nail', model);
},
});
If you're passing
multiple models as an
RSVP.hash
,
you can also alias nested properties:
const { reads } = Ember.computed;
export default Ember.Controller.extend({
people: reads('model.people'),
pets: reads('model.pets')
});