materialize css datepicker options

// Materialize Date Picker

this.instanceDatepicker = new M.Datepicker(this.elDatepicker.nativeElement, {
        defaultDate: new Date(2018,5,4),
        setDefaultDate: true,
        selectMonths: true,
        selectYears: 200, 
        format: "dd/mm/yyyy"

<input type="text" id="Date" class="datepicker" />

In the options listed above, defaultDate and setDefaultDate fail to show the desired date populated in the input. Anything that I may be doing wrong or is this buggy?


Add these lines and it will work

var $input = $('.datepicker').pickadate();
var picker = $input.pickadate('picker');
picker.set('select', new Date(2018, 5, 4));

Leave a Reply

Your email address will not be published. Required fields are marked *