【发布时间】:2017-04-04 16:09:10
【问题描述】:
我已经创建了这个验证函数:
private customValidateField(c: FormControl): any {
return c.value[0] === 'a' ? null : { notValid: true };
}
所以,在我的反应形式上:
constructor(private fb: FormBuilder)
{
this.form = this.fb.group({
field: ['', Validators.required, this.customValidateField],
...
}
}
当我在此字段中写入任何字符时,我会收到此错误:
错误:预期的验证器返回 Promise 或 Observable。
有什么想法吗?
【问题讨论】:
标签: angular typescript