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'; import { DatasetProfileModel } from '../models/DatasetProfileModel'; @Component({ selector: 'section-form', templateUrl: './section-form.component.html', styleUrls: [] }) export class SectionFormComponent { @Input() form: FormGroup; @Input() dataModel:Section; @Input() index:number; constructor(){ } ngOnInit(){ //this.addGroupField(); //for new DatasetProfile } addGroupField(){ let fieldGroup:FieldGroup = new FieldGroup(); if(this.dataModel.fieldGroups) this.dataModel.fieldGroups.push(fieldGroup); (this.form.get("fieldGroups")).push(fieldGroup.buildForm()); } DeleteFieldGroup(index){ this.dataModel.fieldGroups.splice(index); (this.form.get("fieldGroups")).removeAt(index) } }