evansmwendwa / ng2-daterangepicker

Usage Demos update in this url >>>
https://codesandbox.io/s/6yr1zm18w3
MIT License
132 stars 89 forks source link

setStartDate, setEndDate appear not working #144

Closed wotmshuaisi closed 3 years ago

wotmshuaisi commented 3 years ago

Angular version: 7

Ts code:

import { DaterangePickerComponent } from "ng2-daterangepicker";

export class SomeComponent implement OnInit {

    @ViewChild(DaterangePickerComponent) private picker: DaterangePickerComponent;

    public options: any = {
        locale: {
            format: "M/DD/YYYY hh:mm A",
        },
        autoUpdateInput: false,
        alwaysShowCalendars: true,
        timePicker: true
    };

    public updateDateRange() {
        this.picker.datePicker.setStartDate('2017-03-27');
        this.picker.datePicker.setEndDate('2017-04-08');
    }
}

Html code:

<input type="text" name="daterangeInput" daterangepicker [options]="options" (click)="updateDateRange()" style="width: 300px;" />

Click textbox didn't work, why?

wotmshuaisi commented 3 years ago

Text box needs to be manually updated by binding to ngmodule.