Component class

Declare reusable UI building blocks for an application.

Each Angular component requires a single @Component annotation. The @Component annotation specifies when a component is instantiated, and which properties and hostListeners it binds to.

When a component is instantiated, Angular

  • creates a shadow DOM for the component,
  • loads the selected template into the shadow DOM and
  • creates all the injectable objects configured with providers and viewProviders.

All template expressions and statements are then evaluated against the component instance.

Lifecycle hooks

When the component class implements some lifecycle-hooks the callbacks are called by the change detection at defined points in time during the life of the component.

Inheritance

Constructors

Component({String selector, List<String> inputs, Map<String, String> host, String exportAs, List providers, Visibility visibility, List<Object> viewProviders, List<Object> exports, int changeDetection: ChangeDetectionStrategy.Default, String templateUrl, String template, bool preserveWhitespace: true, List<String> styleUrls, List<String> styles, List<Object> directives, List<Object> pipes, ViewEncapsulation encapsulation })
const

Properties

changeDetection → int
Defines the used change detection strategy. [...]
final
directives → List<Object>
final
encapsulation ViewEncapsulation
final
exports → List<Object>
A list of identifiers that may be referenced in the template. [...]
final
pipes → List<Object>
final
preserveWhitespace → bool
Removes all whitespace except &ngsp; and &nbsp; from template if set to false.
final
styles → List<String>
final
styleUrls → List<String>
final
template → String
final
templateUrl → String
final
viewProviders → List<Object>
Defines the set of injectable objects that are visible to its view DOM children. [...]
final
exportAs → String
A name that can be used in the template to assign this directive to a variable. [...]
final, inherited
hashCode → int
The hash code for this object. [...]
read-only, inherited
host → Map<String, String>
Events, actions, properties, and attributes related to the host element. [...]
@Deprecated('Use @HostBinding() on a getter or @HostListener on a method'), final, inherited
inputs → List<String>
The directive's data-bound input properties. [...]
@Deprecated('Use @Input() on a setter or field instead'), final, inherited
providers → List<Object>
The set of injectable objects that are visible to the directive and its light DOM children. [...]
final, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited
selector → String
The CSS selector that triggers the instantiation of the directive. [...]
final, inherited
visibility Visibility
Whether this directive will be provided for injection.
final, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(other) → bool
The equality operator. [...]
inherited