argos/dmp-admin/src/app/section-form/section-form.component.ts

30 lines
727 B
TypeScript

import { Component, OnInit, Input } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { Section } from '../models/Section';
import { FieldGroup } from '../models/FieldGroup';
import { FormArray } from '@angular/forms/src/model';
@Component({
selector: 'section-form',
templateUrl: './section-form.component.html',
styleUrls: []
})
export class SectionFormComponent {
@Input() form: FormGroup;
@Input() dataModel:Section;
constructor(){ }
ngOnInit(){
this.addGroupField();
}
addGroupField(){
let fieldGroup:FieldGroup = new FieldGroup();
this.dataModel.fieldGroups.push(fieldGroup);
(<FormArray>this.form.get("fieldGroups")).push(fieldGroup.buildForm());
}
}