【问题标题】:Date selection doesn't work in Firefox for angular material date picker日期选择在 Firefox 中不适用于角度材料日期选择器
【发布时间】:2019-01-10 11:17:31
【问题描述】:

当我尝试在 Firefox 中的 mat datepicker 上选择日期时,它根本不会选择日期并返回到初始状态。

我在页面上有多个日期选择器,并且该功能在 Edge 和 Chrome 中运行良好。只有 Firefox 没有任何控件/选择起作用

<mat-form-field>
  <input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="picker" (focus)="picker.open()" (click)="picker.open()" readonly [formControl]="dateFormControl" >
  <mat-datepicker #picker></mat-datepicker>
</mat-form-field>

我也需要帮助在 Firefox 上进行日期选择

【问题讨论】:

  • 你能写你的代码吗?以便任何人都可以正确检查问题
  • 添加了我的代码和问题。

标签: angular firefox datepicker angular-material


【解决方案1】:

试试这个:

<mat-form-field>
  <input matInput type="string" [min]="minDate" [max]="maxDate" [matDatepicker]="picker" (focus)="picker.open()" (click)="picker.open()" readonly [formControl]="dateFormControl" >
  <mat-datepicker #picker></mat-datepicker>
</mat-form-field>

它应该可以工作

【讨论】:

  • 我试过这个,但它似乎不起作用。在所有其他浏览器中,似乎调用了更改事件。但在 Firefox 中,更改事件根本不会被调用
  • this.dateFormControl.valueChanges.subscribe((val) => { this.rowItem.validFrom = val; this.componentParent.updateRow(this.rowNode, this.rowItem); });跨度>
  • 你能用 (ngModelChange)="yourFunction()" 试一次吗
  • 也试过这个.. 再一次没有触发更改事件。当我单击 Firefox 中选择的日期中的任何日期时,日历只会关闭并且根本不进行任何选择。如果我们也尝试更改日历上的月份,也会注意到相同的行为
【解决方案2】:

如果您将焦点和单击事件移动到 mat-form-field,则单击事件正常工作,但焦点事件不起作用。

【讨论】:

    猜你喜欢
    • 2018-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多