39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { FormGroup } from '@angular/forms';
|
|
import { JsonSerializer } from '../utilities/JsonSerializer';
|
|
import { SectionFormComponent } from '../section-form/section-form.component';
|
|
import { Section } from '../models/Section';
|
|
import { FieldGroup } from '../models/FieldGroup';
|
|
import { DatasetProfileModel } from '../models/DatasetProfileModel';
|
|
import { TestModel } from '../testModel/testModel';
|
|
import { FormArray } from '@angular/forms/src/model';
|
|
|
|
|
|
@Component({
|
|
selector: 'form-comp',
|
|
templateUrl: './form.component.html',
|
|
styleUrls: []
|
|
})
|
|
|
|
export class FormComponent {
|
|
|
|
dataModel: DatasetProfileModel ;
|
|
form: FormGroup;
|
|
|
|
constructor(){
|
|
}
|
|
|
|
ngOnInit(){
|
|
this.dataModel = new DatasetProfileModel();
|
|
this.dataModel = new JsonSerializer<DatasetProfileModel>().fromJSONObject(TestModel,DatasetProfileModel);
|
|
this.form = this.dataModel.buildForm();
|
|
this.addSection();
|
|
}
|
|
|
|
addSection(){
|
|
let section:Section = new Section();
|
|
this.dataModel.sections.push(section);
|
|
(<FormArray>this.form.get("sections")).push(section.buildForm());
|
|
}
|
|
|
|
} |