File

packages/ui/src/lib/io/output/output.component.ts

Description

Outputs the given field of the given item, rendering the component dynamically.

Extends

DynamicSlotComponent

Implements

OnChanges

Metadata

changeDetection ChangeDetectionStrategy.OnPush
selector ec-output
templateUrl ../dynamic-slot/dynamic-slot.component.html

Index

Properties
Methods
Inputs

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

Methods

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, attributes: Object)
Inherited from DynamicSlotComponent

Loads the given component inside the fieldHost. Sets current item and field by default.

Parameters :
Name Type Optional Default value
component Type<any> No
attributes Object No {}
Returns : ComponentRef<any>

Properties

Public componentFactoryResolver
Type : ComponentFactoryResolver
Inherited from DynamicSlotComponent
fieldHost
Type : SlotHostDirective
Decorators :
@ViewChild(SlotHostDirective, {static: true})
Inherited from DynamicSlotComponent

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>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""