Skip to content
Snippets Groups Projects
form-element-component.directive.ts 590 B
Newer Older
  • Learn to ignore specific revisions
  • import { Directive, Input, OnInit } from '@angular/core';
    
    import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
    
    import { ElementComponent } from './element-component.directive';
    
    export abstract class FormElementComponent extends ElementComponent implements OnInit {
    
      @Input() parentForm!: UntypedFormGroup;
      elementFormControl!: UntypedFormControl;
    
    rhenck's avatar
    rhenck committed
      ngOnInit(): void {
    
        this.elementFormControl = this.parentForm ?
    
          this.parentForm.controls[this.elementModel.id] as UntypedFormControl :
          new UntypedFormControl(this.elementModel.value);