生产构建错误
嗨,我在Angular Project中使用ReactiveForms,当我尝试ng build --prod时,出现以下错误
ng-details/billing-details.component.html (40,6): Property '_touched' is private and only accessible within class 'AbstractControl'.
以下是我的代码,我不知道哪里出错了?
paymentForm = new FormGroup({
companyName: new FormControl('', Validators.minLength(3)),
companyAddress: new FormControl('', Validators.minLength(3)),
gstNumber: new FormControl('', Validators.minLength(3)),
country: new FormControl('', Validators.minLength(3)),
cardNumber: new FormControl('', Validators.pattern('[0-9]{12}')),
cardName: new FormControl('')
});
HTML
<div class="common-error" *ngIf="paymentForm.controls.country._touched && !paymentForm.controls.country.valid"> Please enter Company Name. (Min 3 char)</div>
为什么引用_touched
属性而不是touched
属性?
_touched
是Angular的内部实现细节。请仅使用公共变量。
尝试:
paymentForm.controls.country.touched
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句