0

代码大致如下:

 <div class="inline-field invalid" *ngIf="customerForm.get('customerAddress').errors; else customerAddressValidBlock">
    <input class="form-input field invalid-field" name="customerAddress" type="customerAddress"
           formControlName="customerAddress" placeholder="Customer Address"
           value="{{ customerForm.get('customerAddress').value }}" [focusMe]="data.isFocusOnAddress">
    <div class="field-error">
      <span>Card Holder Name is required</span>
    </div>
  </div>
  <ng-template #customerAddressValidBlock>
    <div class="inline-field valid" *ngIf="customerForm.get('customerAddress').value; else customerAddressBlock">
      <input class="form-input field valid-field" name="customerAddress" type="customerAddress"
             formControlName="customerAddress" placeholder="Customer Address"
             value="{{ customerForm.get('customerAddress').value }}" [focusMe]="data.isFocusOnAddress">
    </div>
  </ng-template>

并且只要在原始 customerAddress 字段中输入任何文本,它就会变得有效,此时它会被替换并且替换字段不会聚焦。

因此,在输入一个字符(或两个如果您输入得非常快)之后,该字段blurs 并且该字段中不再接收到任何字符。事件处理程序是input,我可以从调试工具中看到,但是我从其他人那里继承了这个问题,而且我对 Angular 的了解还不够,无法弄清楚下一步。如果没有错误,它会换出内容。那么换掉内容并重新关注替换字段?

TIA

4

0 回答 0