首页 > 解决方案 > 时刻未设置为时间类型

问题描述

这个问题很奇怪,因为它只发生在国外的用户身上,尽管他们像我一样使用 chrome,而在我的国家(以色列)我没有遇到这个问题。

我正在使用 Angular 2。我为 FormControl 分配时间并将 formControlName 绑定到 type="time"。时间没有设置,我得到一个空字段。

问题: 1. 我怎样才能重现它?考虑到它不会在我国复制。2.如果有人能指出问题,那就太好了。

<div (click)="startTimeInput.click()" class="time-div">
        <mat-form-field fxFlex class="time">
          <input matInput type="time" (TimeChanged)="changeTime($event)" #startTimeInput placeholder="{{'START TIME' | translate}}" formControlName="startTime" required>
        </mat-form-field>
        <mat-icon class="time-picker-button">access_time</mat-icon>
      </div>

 zone.run(() => {
      if (this.unpack(this.data)) {
        this.ShiftForm = new FormGroup({
          role: new FormControl(this.role ? this.role : this.settings ? this.settings.role : this.roleNames[1], Validators.required),
          capacity: new FormControl(this.capacity ? this.capacity : this.settings ? this.settings.capacity : 1, [Validators.required, Validators.pattern(/[0-9]/)]),
          startDate: new FormControl(moment(this.startDate).format('YYYY-MM-DD'), [Validators.required, Validators.pattern(/[0-9]/)]),
          startTime: new FormControl(this.startTime, Validators.required),
          endDate: new FormControl(moment(this.endDate).format('YYYY-MM-DD'), [Validators.required, Validators.pattern(/[0-9]/)]),
          endTime: new FormControl(this.endTime, Validators.required),
          labels: new FormControl(this.labels ? this.labels : this.settings ? this.settings.labels : []),
          forceAssign: new FormControl(this.forceAssignees ? this.forceAssignees : this.membersListedInShift ? this.membersListedInShift : [])
        });
      }
    });
  }

实际:时间是空的

预期:时间已定

标签: htmlangulartimepicker

解决方案


推荐阅读