@Component
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
animations
#
animations?: any[]
changeDetection
#
changeDetection?: ChangeDetectionStrategy
encapsulation
#
encapsulation?: ViewEncapsulation
entryComponents
#
entryComponents?: Array<Type<any>|any[]>
interpolation
#
interpolation?: [string, string]
moduleId
#
moduleId?: string
preserveWhitespaces
#
preserveWhitespaces?: boolean
styleUrls
#
styleUrls?: string[]
styles
#
styles?: string[]
template
#
template?: string
templateUrl
#
templateUrl?: string
viewProviders
#
viewProviders?: Provider[]