Function: ComponentHost()

function ComponentHost<T>(target: undefined, context: ClassFieldDecoratorContext<any, T>): (this: any, initialValue: T) => T;

Defined in: src/behaviors/decorators.ts:137

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type
target undefined
context ClassFieldDecoratorContext<any, T>

Returns

(this: any, initialValue: T): T;

Parameters

Parameter Type
this any
initialValue T

Returns

T

Component Host

field decorator.

Marks a field to receive the host component that contains this behavior. Allows behaviors to access the context (@Ctx) of the component.

Example

Behavior

class Link {

Host

el!: HTMLAnchorElement; // DOM element

Component Host

hostComponent?: BaseComponent; // Component container

@Inject(Router) router!: Router;

onInit() { // Access component context const basePath = (this.hostComponent as any).routeBasePath; // Use basePath for route resolution… } }

// Usage in JSX (no changes needed): <a link href=“sales” activeClass=“active”>Sales</a>