
- EmberJS - Home
- EmberJS - Overview
- EmberJS - Installation
- EmberJS - Core Concepts
- Creating and Running Application
- EmberJS - Object Model
- EmberJS - Router
- EmberJS - Templates
- EmberJS - Components
- EmberJS - Models
- EmberJS - Managing Dependencies
- EmberJS - Application Concerns
- EmberJS - Configuring Ember.js
- EmberJS - Ember Inspector
EmberJS - Loading/Error Substates
The Ember.js overrides transitions for customizing asynchronization between the routes by making use of error and loading substates.
Syntax
Ember.Route.extend ({ model() { //code here } }); Router.map(function() { this.route('path1', function() { this.route('path2'); }); });
Example
The example given below demonstrates the use of Loading / Error Substates which occurs while loading a route. Create a new route and name it as loaderror and open the router.js file with the following code to define URL mappings −
Open the file loaderror.js file created under app/routes/ with the following code −
Open the file application.hbs created under app/templates/ with the following code −
Open the file index.hbs and add the following code −
When you click on the loaderror link, the page should open with the loading state. Therefore, create a loading.hbs file to specify the loading state −
Now open the loaderror.hbs file that displays the error message −
Output
Run the ember server and you will receive the following output −

When you click on the link, it will show the template loading message −

Then it displays an error substate when errors are encountered during a transition −
