29 lines
625 B
TypeScript
29 lines
625 B
TypeScript
import { Component, Input } from '@angular/core';
|
|
import { FormGroup } from '@angular/forms';
|
|
import { Field } from '../models/Field';
|
|
import { Rule } from '../models/Rule';
|
|
import { FormArray } from '@angular/forms/src/model';
|
|
|
|
@Component({
|
|
selector: 'field-form',
|
|
templateUrl: './field-form.component.html',
|
|
styleUrls: []
|
|
})
|
|
|
|
export class FieldFormComponent {
|
|
@Input() form: FormGroup;
|
|
@Input() dataModel: Field;
|
|
|
|
constructon(){}
|
|
|
|
ngOnInit(){
|
|
this.addNewRule();
|
|
}
|
|
|
|
addNewRule(){
|
|
let rule: Rule = new Rule();
|
|
this.dataModel.rules.push(rule);
|
|
(<FormArray>this.form.get("rules")).push(rule.buildForm());
|
|
}
|
|
|
|
} |