Function: Host()
function Host<T>(target: undefined, context: ClassFieldDecoratorContext<any, T>): (this: any, initialValue: T) => T;
Defined in: src/behaviors/decorators.ts:86
Type Parameters
| Type Parameter | Default type |
|---|---|
T |
Element |
Parameters
| Parameter | Type |
|---|---|
target |
undefined |
context |
ClassFieldDecoratorContext<any, T> |
Returns
(this: any, initialValue: T): T;
Parameters
| Parameter | Type |
|---|---|
this |
any |
initialValue |
T |
Returns
T
Host
field decorator.
Marks a field to receive the host element. Works with both:
- Behaviors: BehaviorManager injects the DOM element before calling onInit()
- StyleSheets: BaseStyleSheet injects the component via setHost()
Examples
// In a Behavior:
// In a StyleSheet:
class MyStyles extends BaseStyleSheet {
Behavior
class Tooltip {
Host
el!: HTMLElement;
onInit() { console.log(‘Attached to:’, this.el.tagName); } }
Host
host!: BaseComponent;
@Rule(’:host’) get hostRule() { return { display: ‘block’ }; } }