angular – 在’FormGroup’类型上不存在属性’find’.任何
发布时间:2020-12-17 17:04:44 所属栏目:安全 来源:网络整理
导读:我有简单的角度2形式代码如下 form [formGroup]="myForm" (ngSubmit)="onSubmit()" class="formcss" Usernamebr input type="text" formControlName="username"brbr div Emailbr input id="email" type="text" formControlName="email" div *ngIf="myForm.fi
我有简单的角度2形式代码如下
<form [formGroup]="myForm" (ngSubmit)="onSubmit()" class="formcss"> Username<br> <input type="text" formControlName="username"><br><br> <div> Email<br> <input id="email" type="text" formControlName="email"> <div *ngIf="myForm.find('email').valid">Invalid Email</div><br><br> Password<br> </div> <input type="text" formControlName="password"><br><br> <h3>Hobbies</h3> <input type="text"><br><br> <button>Add Hobby</button> <button type="submit" [ngStyle]="{ background:'green'}" [disabled]="!myForm.valid">Submit</button> </form> 我试图显示消息“无效的电子邮件”是电子邮件提交不通过验证器,但得到此错误 error_handler.js:45 EXCEPTION: self.context.myForm.find is not a function 我正在使用角度2的最终版本.任何想法? 解决方法find 已从RC6中的AbstractControl(FormGroup的超类)中删除.你应该使用
get 代替
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |