Explain "Hello World " in Aurelia

 Posted by Rajnilari2015 on 8/24/2016 | Category: JavaScript Interview questions | Views: 315 | Points: 40
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 

Comments or Responses

Login to post response