【问题标题】:Edit clear button method in ngx daterange picker在 ngx 日期范围选择器中编辑清除按钮方法
【发布时间】:2020-10-15 03:50:57
【问题描述】:

我正在尝试动态设置日历的 minDate 和 maxDate。我使用了几种方法来做到这一点,但是,我想使用“清除”按钮将这些值重置为 null

在我的 .ts 中有这个:

startDateClicked($event) {
    this.maxDate = moment($event.startDate._d).add(7, 'days');
  }
  endDateClicked($event) {
    this.minDate = moment($event.endDate._d).subtract(7, 'days');
  }

在我的 html 中,我有这个:

<input type="text" ngxDaterangepickerMd formControlName="pick_dates"
                class="form-control" placeholder="Select" [ranges]="ranges" [alwaysShowCalendars]="true"
                [showClearButton]="true" [keepCalendarOpeningWithRange]="true"
                opens="center"
                [showRangeLabelOnInput]="true"  
                [maxDate]='maxDate' (startDateChanged)="startDateClicked($event)"
                (endDateChanged)="endDateClicked($event)" [timePicker]="true" [locale] = "locale"/>

在清除按钮方法中我想设置这个:

this.maxDate=null
this.minDate=null

【问题讨论】:

  • 我找到参数了!!!在 html 中只需添加 [dateLimit]=7,就我而言,它在“天”内工作

标签: angular daterangepicker bootstrap-daterangepicker


【解决方案1】:

您需要在最大和最小日期中输入一些默认日期。

this.minDate=moment(new Date()).subtract(1, 'month');
 this.maxDate = moment(new Date()).add(1, 'month');

【讨论】:

    【解决方案2】:

    我找到参数了!!!在html中添加

    [dateLimit]=7
    

    ,就我而言,它在“天”内起作用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-18
      • 1970-01-01
      • 2020-11-17
      • 1970-01-01
      相关资源
      最近更新 更多