Defining routes with templates

Another job of the route handler is rendering the appropriate template. Here is a recipe that goes over this.

How to do it...

In this recipe, we'll create a few nested routes and check where they get rendered.

  1. In a new project, create a new students and schools route:
    $ ember g route schools
    $ ember g route schools/students
    

    This will create the nested students and schools route.

  2. Let's take a look at the router.js file:
    // 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('schools', {}, function() {
        this.route('students', {});
      });
    });
    
    export default Router;

    The generated command already ...

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.