InfomediaLtd / angular2-materialize

Angular 2 support for Materialize CSS framework.
https://infomedialtd.github.io/angular2-materialize/
MIT License
407 stars 140 forks source link

Datepicker handlers #47

Closed pchristou closed 8 years ago

pchristou commented 8 years ago

Hi,

In short, I have 2 questions.

  1. How can I close the datepicker on selection?
  2. Why does this datepicker implementation not suffer from this bug whereas Materialize's one (and mine) does?

Longer explanation:

I understand Materialize uses pickadate.js under the covers. Having checked its API I see there are a range of event callbacks available: callback_handlers

How can I apply these to the datepicker in Angular 2? I got as far as grabbing the datepicker through

        var $input =$(this.el.nativeElement); // We grab a reference to the datepicker here
        var picker = $input.pickadate('picker');

but there's not a great deal I can do from there. I actually want to close the datepicker on selection and found that an attribute 'closeOnSelect' exists: http://amsul.ca/pickadate.js/date/

Unfortunately, placing this in [materializeParams] doesn't seem to work.

One more thing, I noticed the Datepicker sample here http://angular2-materialize.surge.sh/#/datepicker does not suffer from this bug whereas Materializes (plus mine) does... can you think of any reasons why? I thought the implementation between both would be near identical...

As always, thank you! Pieris

pchristou commented 8 years ago

Got this sorted.

For the date handling part, I used:


        var $input = $(this.el.nativeElement); // We grab a reference to the datepicker here
        var picker = $input.pickadate('picker');
        picker.on('close', function() {
          //...
        })
marciomsm commented 7 years ago

Are we able to use events callback already? Do anyone knows how to do it in Angular 2?

rubyboy commented 7 years ago

See here: https://github.com/InfomediaLtd/angular2-materialize/issues/283

<input materialize="pickadate" [materializeActions]="actions" type="text" />
this.actions.emit({action:"pickadate",params:["close"]});