如題…
errors只列印出required
試過minLength(),maxLength(),parttern都列印不出來…
是哪裡寫錯了嗎…??
列印出的結果---
startNum: FormControl
errors:
required: true
__proto__: Object
pristine: true
status: "INVALID"
程式碼
html
<form [formGroup]="form">
<input
type="number"
class="input"
formControlName="startNum">
ts
public form!: FormGroup;
constructor(private fb: FormBuilder,) {}
ngOnInit(): void {
this.form = this.fb.group({
startNum: new FormControl('',{
validators: [
Validators.minLength(4),
Validators.required,
Validators.pattern('\d{7}')
],
}),
});
}
找不到問題出在哪@@~感恩~