I have an item that needs to generate a form
const textBox = {
fontColor: 'blue',
fontSize: '18',
placeholder: 'email',
name: 'input email',
label: 'john',
validation: {
required: false
}
};
I developed a dynamic form but now I want to assign validators to each form control
ngOnInit(): void {
const formDataObject = {} as any;
for (const key of Object.keys(this.InputObj)) {
debugger;
if (key !== 'validation') {
formDataObject[key] = new FormControl(this.InputObj[key]);
this.formControls.push(key);
}
}
this.form = new FormGroup(formDataObject);
}
I am looking to add validation rules to the form controls, but some objects may not require any validations