什么是不正确的?如果错误如何使其正确,我想显示此属性?
<label for="email" *ngIf="(form.controls.email.errors && form.controls.email.dirty) ? true : [attr.data-error]="wrong" ">E-Mail</label>
<input type="email" name="email" autocomplete="off" formControlName="email">
答案 0 :(得分:1)
<label for="email" [attr.data-error]="(form.controls.email.errors && form.controls.email.dirty)? 'wrong': null">E-Mail</label>
答案 1 :(得分:0)
您可以尝试这样的事情
<label for="email"
*ngIf="form.controls.email.errors && form.controls.email.dirty"
[attr.data-error]="form.controls.email.errors && form.controls.email.dirty?
'wrong': ''" >
E-Mail</label>