@component
@component
[1]. <T extends Component>(componentType?:
ComponentConstructor
<
Component
>): PropertyDecorator
[2]. <T extends Component>(target: T, propertyKey: any): void
Property decorator: amend decorated property to turn it into a managed child component reference of given type. Also presets bindings from given component type on the parent component (see Component.presetBoundComponent()
, which allows for greater control of the resulting bindings).
This asserts a parent-child ‘composition’ dependency between the referrer and the referenced object(s):
This property can only be assigned a reference to a
Component
instance of given type.When the parent is destroyed, all children are also destroyed.
When the decorated property is set to another object, the previously referenced object is destroyed.
When the referenced object is assigned to another managed child reference (or list, map, or reference instance that is a child object), the decorated property is set to undefined.
The child object may refer to its parent using the
Component.getParentComponent()
andComponent.getBoundParentComponent()
methods.
Note: : The component type parameter is optional, this decorator can be used both on its own or with a class parameter.