UNPKG

@codeforges/ng-forms

Version:

Angular 4+ Dynamic form builder, decorate your models to generate forms or create them manually

25 lines 936 B
import { FormControl, Validators } from "@angular/forms"; export class BaseInput { constructor(name, inputParams) { this.name = name; if (inputParams) { this.label = inputParams.label; this.required = inputParams.required; this.disabled = inputParams.disabled; this.order = inputParams.order; this.placeholder = inputParams.placeholder; this.controlType = inputParams.controlType; this.value = inputParams.value; } this.formControl = this.buildFormControl(); } getFormControl() { return this.formControl; } buildFormControl() { return this.required ? new FormControl({ value: this.value, disabled: this.disabled } || '', Validators.required) : new FormControl({ value: this.value, disabled: this.disabled } || ''); } } //# sourceMappingURL=BaseInput.js.map