O'Reilly logo

Ember.js Cookbook by Erik Hanchett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining an application route

When loading your application, the router looks at the URL and matches it to the route. We'll go over some basics on how this works.

How to do it...

The route map is used to define the URL mappings. Let's take a look at adding a new route using this.route.

  1. In a new application, open the router.js file in the app folder. To begin, we'll create a new route called about:
    // 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('about');
    });
    
    export default Router;

    Router.map in the preceding code handles the routing of the program. The this.route creates the about route. By default, the name ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required