Sitemap

What is the component in Angular?

May 1, 2021
Press enter or click to view image in full size

Component is an element of the Angular app. They are the main building blocks. Each component is a type of directive. Component is made of class with Component metadata, html template, css selector and optionally css style apply to html template. Component have lifecycle hooks.

Cli command

ng g c app-component-overview

Syntax :-

@Component({

selector: ‘app-component-overview’,

templateUrl: ‘./component-overview.component.html’,

styleUrls: [‘./component-overview.component.css’]

})

export class ComponentOverviewComponent {

}

--

--

Anil Kumar
Anil Kumar

Written by Anil Kumar

Software Engineer| Angular Advocate | Cyclist