while building crud app in angular 5 I\'ve come across with a question, how can I use the same form builder but change what form controls I get depending on what I want, adding
addControl RemoveControl using u can hide and show your Fields.
{{ projectData?.description }}
Add control:
editField(this.formControlKeys.description){
this.detailForm.addControl('description', new FormControl(''));
this.detailForm.controls['description'].setValue(this.projectData.description);
}
remove control:
removeDescriptionControl() {
this.detailForm.removeControl('description');
}
create form group first:
this.detailForm = this.formBuilder.group({
});
set formControlKeys:
formControlKeys = {
description: 'description'
};