EmberJS - Router

Router is a core feature of EmberJs which translates an URL into a series of templates and represents the state of an application.The Ember uses the router to map the URL to a route handler. The router matches the current URL to other routes which are used for loading data, displaying the templates and to set up an application state.

Route handler performs some actions such as −

  • It provides the template.

  • It defines the model and it will be accessible to the template.

  • If there is no permission for user to visit the particular part of an app, then router will redirect to a new route.

The following table lists down the different routers in Ember.js along with their description −

S.No. Types & Description
1 Defining Routes

The router matches the current URL with routes responsible for displaying template, loading data and setting up an application state.

2 Specifying a Route's Model

To specify a routes model, you need a template to display the data from the model.

3 Rendering a Template

The routes are used to render the external template to the screen.

4 Redirecting

It is a URL redirection mechanism that redirects the user to a different page when the requested URL is not found.

5 Preventing and Retrying Transitions

The transition.abort() and transition.retry() methods can be used to abort and retry the transition respectively during a route transition.

6 Loading/Error Substates

Ember router provides information of a route loading and errors which occur when loading a route.

7 Query Parameters

Query parameters come into view at the right side of the “?” mark in a URL represented as optional key-value pairs.

8 Asynchronous Routing

Ember.js router has the ability to handle complex async logic within an application by using asynchronous routing.