Creating the component

First off, let's import the component decorator:

import { Component } from '@angular/core';

Then create the class for your component:

class AppComponent {
title:string = 'hello app';
}

Then decorate your class using the Component decorator:

@Component({
selector: 'app',
template: `<h1>{{ title }}</h1>`
})
export class AppComponent {
title: string = 'hello app';
}

We give the Component decorator, which is function, an object literal as an input parameter. The object literal consists at this point of the selector and template keys, so let's explain what those are.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset