首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么matInput文本字段显示[object FocusEvent]而不是我在Angular 8中使用(模糊)的实际文本

为什么matInput文本字段显示[object FocusEvent]而不是我在Angular 8中使用(模糊)的实际文本
EN

Stack Overflow用户
提问于 2021-01-05 00:04:10
回答 1查看 33关注 0票数 0

代码语言:javascript
复制
  fetchContractNumber(contractNumber: any): void {
    this.changeField(contractNumber, 'vehicle.previousContractNumber');
    if (contractNumber) {
      this.s1 = this.facade.fetchContractNumber(this.equipmentModel.previousContractNumber).subscribe(data => {
        this.equipmentModel.previousWarrantyExpiryOdometer = data.data.contracts[0].expirationOdometer;
        this.equipmentModel.previousWarrantyExpiryDate = data.data.contracts[0].expirationDate;
        this.changeField(data.data.contracts[0].expirationOdometer, 'vehicle.previousWarrantyExpiryOdometer');
        this.changeField( data.data.contracts[0].expirationDate, 'vehicle.previousWarrantyExpiryDate');
      });
    }
  }
代码语言:javascript
复制
<mat-form-field class="w-4/12 xl:w-4/12 pr-1">
            <input
              matInput
              (blur)="fetchContractNumber($event)"
              name="previousContractNumber"
              [ngModel]="equipmentModel.previousContractNumber"
              placeholder="{{ 'previouscontractnumber' | translate }}"
              type="text"
              #previousContractNumber="ngModel"
              [errorStateMatcher]="errorStateMatcher('vehicle.previousContractNumber', dealError)"
              [ngDave2EditableField]="dealIsLocked"
              editableFieldgroup="equipment"
              editableFieldCode="previousContractNumber"
              [editableDealStatus]="dealStatus"
            />
            <button
              mat-button
              *ngIf="equipmentModel.previousContractNumber && !dealIsLocked"
              matSuffix
              mat-icon-button
              aria-label="Clear"
              (click)="resetPreviousContractNumberFields()"
            >
              <mat-icon>close</mat-icon>
            </button>
            <mat-error>
              {{ 'required' | translate }}
            </mat-error>
          </mat-form-field>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-05 00:53:57

从你的方法看来,你期望从你的模糊事件绑定中传递的$event是一个数字(所以大概是一个数字),但事实并非如此。您可能需要$event.target.value

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65565787

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档