1
我有这样的代码组件:如何检查FormGroup输入角
this.loginForm = this._fb.group({
phone: ['', [<any>Validators.required, <any>Validators.minLength(5)]],
password: ['', [<any>Validators.required, <any>Validators.minLength(7)]]
});
在形式上,我试图表明的消息,如果输入是无效的:
<small [hidden]="loginForm.controls.phone.invalid || (loginForm.controls.phone.pristine && !submitted)" class="text-danger">
但事实并非如此为我工作
这'loginForm.controls.phone.pristine'给我一个错误:'未定义phone' – OPV
也许用'loginForm.controls [ '电话'] pristine'? – OPV
它不起作用,仍然是一个错误:undefined phone – OPV