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.
The route map is used to define the URL mappings. Let's take a look at adding a new route using this.route
.
In a new application, open the
router.js
file in theapp
folder. To begin, we'll create a new route calledabout
:// 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. Thethis.route
creates theabout
route. By default, the name of the route will be the same as the path to it. For example, theabout
route path would be located at/about
. We can specifically set the path usingpath
.Instead of having all requests go to
/about
, let's change the path so that they go to...