di-controls
Version:
<!-- PROJECT LOGO -->
32 lines (31 loc) • 1.35 kB
TypeScript
import { InjectionToken, InjectOptions, Provider, Type } from '@angular/core';
import { DIControl } from 'di-controls/controls';
export declare const DI_HOST_CONTROL: InjectionToken<DIControl<unknown>>;
/**
* Returns provider that can be used to provide host control. You can use it in the `providers` section
* of your `@Component` or `@Directive`.
*
* ```ts {2} fileName="custom-control.component.ts"
* @Component({
* providers: [provideHostControl(CustomControlComponent)],
* })
* export class CustomControlComponent extends DIControl<string> {
* constructor() {
* super();
* }
* }
* ```
*
* @param useExisting - The `@Component` or `@Directive` class that should be used as a host control.
*/
export declare function provideHostControl<T extends DIControl<any>>(useExisting: Type<T>): Provider;
/**
* Injects host control. You can use it in the constructor of your `@Component` or `@Directive`.
*
* @param options - Options that can be used to configure injection.
*/
export declare function injectHostControl<T, C extends DIControl<T> = DIControl<T>>(): C;
export declare function injectHostControl<T, C extends DIControl<T> = DIControl<T>>(options?: InjectOptions & {
optional?: false;
}): C;
export declare function injectHostControl<T, C extends DIControl<T> = DIControl<T>>(options: InjectOptions): C | null;