I am trying to add a formGroup to my overall form conditional on a specific field being of a certain type in my case. My function to add this formGroup looks like this:
initSocial() {
const group = <FormGroup>this.cardForm;
group.addControl(
'social': this._fb.group({
'fb': new FormControl(this.currentCard.social.fb),
'yt': new FormControl(this.currentCard.social.yt),
'ig': new FormControl(this.currentCard.social.ig),
'tw': new FormControl(this.currentCard.social.tw),
})
)
}
Right now I am getting a typescript error under the colon after 'social' saying a ',' is expected. I haven't been able to test this to see if addControl() will even work.
My function to fire initSocial is in ngOnInit and looks like this:
if(this.currentCard.cardType === "brand"){
this.initSocial();
}
Any help/tips/suggestions would be much appreciated.