I have a formgroup in which I placed a formArray field which has three form fields in itself, like socialId, socialSlug and socialUrl.

and I have a collection of 30 social media names. Which I want to loop through it and populate a formArray field for each of the social media object.

The formgroup itself optional but there should be a validation for the url

this.socialProfileLinkForm = this.fb.group({
            social_profile: this.fb.array([], Validators.minLength(0))
this.candidateService.getAvailableSocialProfileList().subscribe((val: any) => {
            this.socialProfileList = val.body;

and i am iterating through socialProfileList in the html to produce the form


on click on the link btn url field comes and clicking on save btn it will save a form object into that formArray

0 Answers