我正在使用角度2模板驱动形式工作。我有一个问题。value.errors.required和value.errors有什么区别。任何人都可以清楚地解释吗?如果我使用必填项,则会收到类似“ ERROR 错误:无法读取null属性“ required”。正确的是“ zipcode.errors.required”(或zipcode.errors)
<div *ngIf="zipcode1.invalid || zipcode2.invalid)&&forms.submitted&&
(zipcode1.errors.required || zipcode2.errors.required")>
<div *ngIf="zipcode1.errors.required || zipcode2.errors.required">Please
type</div>
</div>
<div *ngIf="zipcode1.invalid || zipcode2.invalid)&&forms.submitted&&
(zipcode1.errors.required || zipcode2.errors.required ")>
<div *ngIf="zipcode1.errors.required || zipcode2.errors.required">Please
type</div>
</div>
和
<div *ngIf="zipcode1.errors|| zipcode2.errors">Please type</div>
</div>
<div *ngIf="zipcode1.invalid || zipcode2.invalid)&&forms.submitted&&
(zipcode1.errors|| zipcode2.errors")>
<div *ngIf="zipcode1.errors|| zipcode2.errors">Please type</div>
</div>