0 votes
in Angular by

What are components?

1 Answer

0 votes
by
Components are the most basic UI building block of an Angular app, which form a tree of Angular components. These components are a subset of directives. Unlike directives, components always have a template, and only one component can be instantiated per element in a template. Let's see a simple example of Angular component

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

@Component ({

   selector: 'my-app',

   template: ` <div>

      <h1>{{title}}</h1>

      <div>Learn Angular6 with examples</div>

   </div> `,

})

export class AppComponent {

   title: string = 'Welcome to Angular world';

}
...