In this chapter we will show you how to configure Aurelia framework
for your needs. Sometimes you will need to set initial configuration or
run some code before the app is rendered to the users.
You also need to tell Aurelia to load configuration module. You can see the commented part in the example below.
Step 1 - Create main.js
Let's create main.js file inside src folder. Inside this file we will configure Aurelia.You also need to tell Aurelia to load configuration module. You can see the commented part in the example below.
index.html
<!DOCTYPE html> <html> <head> <title>Aurelia</title> <link rel = "stylesheet" href = "styles/styles.css"> <meta name = "viewport" content = "width=device-width, initial-scale = 1"> </head> <body aurelia-app = "main"> <!--Add "main" value to "aurelia-app" attribute... --> <script src = "jspm_packages/system.js"></script> <script src = "config.js"></script> <script> SystemJS.import('aurelia-bootstrapper'); </script> </body> </html>
Step 2A - Default Configuration
The code below shows how to use default configuration. configure function allow us to set configuration manually. We are settings use property to specify what we need.main.js
export function configure(aurelia) { aurelia.use .standardConfiguration() .developmentLogging(); aurelia.start().then(() => aurelia.setRoot()); }
Step 2B - Advanced Configuration
There are lots of configuration options we could use. It is out of the scope of this article to show you all of it so we will explain how the configuration works on the following example. We are basically telling Aurelia to use default data binding language, default resources, development logging, router, history and event aggregator. These are standard set of plugins.export function configure(aurelia) { aurelia.use .defaultBindingLanguage() .defaultResources() .developmentLogging() .router() .history() .eventAggregator(); aurelia.start().then(() => aurelia.setRoot()); }NOTE − These settings will be explained in detail in our Aurelia - Plugins chapter.
No comments:
Post a Comment