Answer: Let us first create the app.js file inside the src folder and write the below
app.js
---------
export class App{
constructor() {
this.sayHello = "Hello World";
}
}
It is the model. The sayHello is the property that we will bind to the view. The Constructor method is used for initializing object created inside a class.
Now, let us create the view which is app.html file inside the src folder and write the below
app.html
--------
<template>
<div>${sayHello}</div>
</template>
The sayHello property is bound to the HTML template by using ${sayHello} syntax. It is the one way binding.
Now create the main.js file inside the src folder
main.js
---------
export function configure(aurelia) {
aurelia.use.basicConfiguration();
aurelia.start().then(() => aurelia.setRoot());
}
This tells Aurelia to configure itself by exporting a configure method using the basicConfiguration. The setRoot method is the root of the UI component tree that Aurelia needs to render.
Asked In: Many Interviews |
Alert Moderator