ng2-daterangepicker用选定的startDate设置minDate

时间:2017-06-26 11:27:37

标签: angular daterangepicker

我的html与开始日期和结束日期一起使用。必须选择结束日期值,并将开始日期作为结束日期的开始日期。

<div class="input-group" [options]="singlePicker" (selected)="selectStartDate($event)" daterangepicker>
    <span class="form-control uneditable-input" name="start">
        {{ startDate | date: 'M/dd/y' }}
    </span>
</div>
<div class="input-group" [options]="singleEndPicker"
(selected)="selectEndDate($event)" daterangepicker>
    <span class="form-control uneditable-input" name="start">
        {{ endDate | date: 'M/dd/y' }}
    </span>
</div>

组件为日期选择器提供单独的选项。

/* Option for startDate*/
public singlePicker = {
    singleDatePicker: true,
    showDropdowns: true,
    opens: "left"
}
/* Option for endDate*/
public singleEndPicker = {    
    singleDatePicker: true,
    showDropdowns: true,
    opens: "left",
    minDate: moment().local().format('MM/DD/YYYY') // need to set the startDate here
 }

如何将minDate选项设置为选定的startDate值?

1 个答案:

答案 0 :(得分:0)

当前版本现在支持更改检测,您应该能够在每次选择后更新minDate,只需更新它