argos/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/auto-complete/description-template-editor...

27 lines
963 B
TypeScript

import { Component, Input, OnInit } from '@angular/core';
import { UntypedFormArray, UntypedFormGroup } from '@angular/forms';
import { DescriptionTemplateExternalSelectDataEditorModel } from '../../../description-template-editor.model';
@Component({
selector: 'app-description-template-editor-auto-complete-field-component',
styleUrls: ['./description-template-editor-auto-complete-field.component.scss'],
templateUrl: './description-template-editor-auto-complete-field.component.html'
})
export class DescriptionTemplateEditorAutoCompleteFieldComponent implements OnInit {
@Input() form: UntypedFormGroup;
multiForm: UntypedFormArray;
ngOnInit() {
this.multiForm = (<UntypedFormArray>this.form.get('data').get('sources'));
}
addSource() {
(<UntypedFormArray>this.multiForm).push(new DescriptionTemplateExternalSelectDataEditorModel().buildForm());
}
removeSource(index: number) {
(<UntypedFormArray>this.multiForm).removeAt(index);
}
}