packages/ui/src/lib/io/output/output.component.ts
Outputs the given field of the given item, rendering the component dynamically.
changeDetection | ChangeDetectionStrategy.OnPush |
selector | ec-output |
templateUrl | ../dynamic-slot/dynamic-slot.component.html |
Properties |
Methods |
Inputs |
component | |
Type : Type<any>
|
|
Overrides the default component |
field | |
Type : Field
|
|
The instance of field that should be used in the template |
item | |
Type : Item<any>
|
|
The belonging item |
ngOnChanges |
ngOnChanges()
|
The component is loade as soon as the field and item are known. If the field has no output property set, the DefaultOutputComponent will be rendered.
Returns :
void
|
loadComponent | ||||||||||||
loadComponent(component: Type
|
||||||||||||
Inherited from
DynamicSlotComponent
|
||||||||||||
Defined in
DynamicSlotComponent:17
|
||||||||||||
Loads the given component inside the fieldHost. Sets current item and field by default.
Parameters :
Returns :
ComponentRef<any>
|
Public componentFactoryResolver |
Type : ComponentFactoryResolver
|
Inherited from
DynamicSlotComponent
|
Defined in
DynamicSlotComponent:14
|
fieldHost |
Type : SlotHostDirective
|
Decorators :
@ViewChild(SlotHostDirective, {static: true})
|
Inherited from
DynamicSlotComponent
|
Defined in
DynamicSlotComponent:11
|
The FieldHostDirective will be used to nest custom components into the field |
import {
Component,
Input,
OnChanges,
ChangeDetectionStrategy,
Type
} from '@angular/core';
import { DynamicSlotComponent } from '../dynamic-slot/dynamic-slot.component';
import { Field, Item } from '@ec.components/core';
import { DefaultOutputComponent } from '../../form/default-output/default-output.component';
/** Outputs the given field of the given item, rendering the component dynamically. */
@Component({
selector: 'ec-output',
templateUrl: '../dynamic-slot/dynamic-slot.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class OutputComponent extends DynamicSlotComponent implements OnChanges {
/** The instance of field that should be used in the template */
@Input() field: Field;
/** The belonging item */
@Input() item: Item<any>;
/** Overrides the default component */
@Input() component: Type<any>;
/** The component is loade as soon as the field and item are known.
* If the field has no output property set, the DefaultOutputComponent will be rendered. */
ngOnChanges() {
if (this.field && this.item) {
this.loadComponent(
this.component || this.field.output || DefaultOutputComponent,
{
item: this.item,
field: this.field
}
);
}
}
}
<ng-template ecSlotHost></ng-template>