我是角度新手。我发现该代码具有三种变体。我想知道这三者在响应式表单(表单组、表单生成器和表单控件)中实现有什么区别。
是否存在基于一种方法的应用程序性能相对于另一种方法的优先级,或者这只是偏好?
addressFormControl = new FormControl(undefined, [
Validators.required,
Validators.address,
]);
export class BusinessComponent {
BusinessForm = new FormGroup({
email: this.emailFormControl,
firstName: new FormControl(''),
lastName: new FormControl(''),
address: new FormGroup({
street: new FormControl(''),
city: new FormControl(''),
state: new FormControl(''),
zip: new FormControl('')
})
});
}
export class BusinessComponent {
constructor(private fb: FormBuilder) { }
businessForm = this.fb.group({
business: this.businessFormControl,
firstName: [''],
lastName: [''],
address: this.fb.group({
street: [''],
city: [''],
state: [''],
zip: ['']
}),
});
}
Run Code Online (Sandbox Code Playgroud) typescript form-control angular angular-reactive-forms formgroups