- EmberJS Tutorial
- 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 Useful Resources
- EmberJS - Quick Guide
- EmberJS - Useful Resources
- EmberJS - Discussion
EmberJS - Initializers
Initializers are used to configure an application as it boots. Initializers contain two types −
Application Initializers − An application initializer runs as your application boots and configures the dependency injection in your application.
Application Instance Initializers − An application instance initializers run when an application instance is loaded and configures the initial state of an application.
Application Initializers
Application initializers can be created by using the following command −
ember generate initializer initializer-name
When you create an initializer, it will display the following code format −
export function initialize(/* application */) { //application.inject('route', 'foo', 'service:foo'); } export default { //'logger' is an application initializer name name: 'logger', initialize };
Application Instance Initializers
An instance initializer for an application can be created by using the following command −
ember generate instance-initializer instance-initializer-name
When you run the above command, it will display the the following code structure −
export function initialize(/* appInstance */) { // appInstance.inject('route', 'foo', 'service:foo'); } export default { //'logger' is an application instance initializer name name: 'logger', initialize };
For more about these two initializers along with an example, see this link.
To Continue Learning Please Login
Login with Google