Displaying a list of items
Often, you'll have a list of items that you'll need to iterate over. We can iterate through these items with the each
helper. This recipe will go over how to do this.
How to do it...
Let's say that we have a list of students and want to display them in our template. We'll use the each
helper to accomplish this.
- In a new project, generate
student
controller
andtemplate
:$ ember g template student $ ember g controller student
This will create the necessary files needed for our example.
- Update the
router.js
file with the newstudent
route:// app/router.js … Router.map(function() { this.route('student'); });
This will add a new
conditional
route. To access this route using the Ember server, open a web browser and navigate to ...
Get Ember.js Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.