Occasionally, you'll need to retrieve data from a model for a template. The route is responsible for loading the appropriate model. This recipe will go over how to do this.
In a new application, open the
router.js
file and add a new route. We'll call this routestudents
:// app/router.js import Ember from 'ember'; import config from './config/environment'; var Router = Ember.Router.extend({ location: config.locationType }); Router.map(function() { this.route('students'); }); export default Router;
The
students
route will retrieve data from thestudents
route handler.Generate the
students
route. This will create thestudents
route handler and template:$ ember g route students
In the
students.js
file, add a new model that returns a JavaScript object:// app/routes/students.js import Ember from 'ember'; export default Ember.Route.extend({ model() { return [1,2,3,4,5,6,7]; } });
The
model
hook normally returns an Ember Data record. However...