I am trying to use Validators on my form inputs but get this error Cannot create property 'validator' on string 'clientUserName' I would like to resolve this error.
My html
<form [formGroup]= "userInfoForm" (ngSubmit)="onUserInfoFormSubmit()">
<mat-form-field>
<mat-label>User Name</mat-label>
<input id="clientUserName" type="text" formControl="clientUserName" matInput>
</mat-form-field>
</form>
My ts
export class ManageAccountClientComponent implements OnInit {
userInfoForm: FormGroup;
constructor(
private formBuilder: FormBuilder
) { }
ngOnInit(): void {
this.userInfoForm = this.formBuilder.group({
clientUserName: ['', Validators.required]
});
}
onUserInfoFormSubmit(){
window.alert('UserInfoFormSubmit');
}
}