How to append new FormGroup or FormControl to form




 
public registerForm!: FormGroup;
 constructor(
    private _fb: FormBuilder
  ) { }
  
  ngOnInit(): void {
    const self = this;
    self._createRegisterForm();
  }
private _createRegisterForm(): void {
    const self = this;
    self.registerForm = self._fb.group({
      email: ['', [Validators.required, Validators.email]]
    });
    // To Appended field
    self.registerForm = self._fb.group({
      ...self.registerForm.controls,
      password: ['', Validators.required],
      password_confirmation: ['', Validators.required],
    }, {
      validator: MustMatch('password', 'password_confirmation')
    })
}
Share on Google Plus

About Ram Pukar

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

0 comments:

Post a Comment