ember/alias-model-in-controller
January 29, 2026 ยท View on GitHub
It makes code more readable if the model has the same name as a subject.
Examples
We can do this in two ways:
-
Alias the model to another property name in the Controller:
import Controller from '@ember/controller'; import { alias } from '@ember/object/computed'; export default Controller.extend({ nail: alias('model'), }); -
Set it as a property in the Route's
setupControllermethod:import Route from '@ember/routing/route'; export default 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:
import Controller from '@ember/controller';
import { reads } from '@ember/object/computed';
export default Controller.extend({
people: reads('model.people'),
pets: reads('model.pets'),
});
Help Wanted
| Issue | Link |
|---|---|
| โ Missing native JavaScript class support | #560 |