@Component
This is the documentation for Angular 6.
You can switch to the latest version Angular 10.
You can switch to the latest version Angular 10.
Components are the most basic UI building block of an Angular app.
Angular components are a subset of directives, always associated with a template. Unlike other directives, only one component can be instantiated per an element in a template.
A component must belong to an NgModule
in order for it to be available to another component or application. To make it a member of an NgModule
, list it in the declarations
field of the @NgModule
metadata.
Example
import {Component} from '@angular/core';
@Component({
selector: 'my-component',
template: `Hello there!`
})
export class MyComponent {
...
}
Options
Inherited from Directive decorator
changeDetection
#
changeDetection: ChangeDetectionStrategy
viewProviders
#
viewProviders: Provider[]
moduleId
#
moduleId: string
templateUrl
#
templateUrl: string
template
#
template: string
styleUrls
#
styleUrls: string[]
styles
#
styles: string[]
animations
#
animations: any[]
encapsulation
#
encapsulation: ViewEncapsulation
interpolation
#
interpolation: [string, string]
entryComponents
#
entryComponents: Array<Type<any> | any[]>
preserveWhitespaces
#
preserveWhitespaces: boolean