Created
November 12, 2021 20:39
-
-
Save dontpaniclabsgists/557bb108bb447edd6ec1414ddd05a289 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { FormArray, FormBuilder, FormControl, Validators } from '@angular/forms'; | |
@Component({ | |
selector: 'app-company-view', | |
templateUrl: './company-view.component.html', | |
styleUrls: ['./company-view.component.scss'] | |
}) | |
export class CompanyViewComponent implements OnInit { | |
adminForm = this.fb.group({ | |
name: new FormControl('', [Validators.required]), | |
email: new FormControl('', [Validators.required, Validators.email]), | |
}); | |
companyForm = this.fb.group({ | |
companyName: new FormControl('', [Validators.required]), | |
admins: this.fb.array([]) | |
}) | |
constructor(private fb: FormBuilder) { } | |
ngOnInit(): void { | |
} | |
get admins() { | |
return this.companyForm.controls["admins"] as FormArray; | |
} | |
addNewAdmin(){ | |
this.admins.push(this.adminForm); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment