ng2-ui / datetime-picker

Angular2 DateTime Picker
https://ng2-ui.github.io/#/datetime-picker
MIT License
121 stars 62 forks source link

close on select, not interpreted #127

Closed TwanoO67 closed 7 years ago

TwanoO67 commented 7 years ago

Hello guys,

I'm trying to use the datetimepicker like that:

<input
    ng2-datetime-picker
    [close-on-select]="false"
    [ngModel]="myDate | timestampToDate:'DD/MM/YYYY [à] HH:mm:ss'"
        (valueChanged)="changeMyDate($event)"
    [date-format]="'DD/MM/YYYY [à] HH:mm'"
 >

with my changed function like that:

private changeDateCreation(date, format='DD/MM/YYYY [à] HH:mm:ss'){
      moment.locale('fr');
      this.mydate = parseInt( moment(date,format).format('X') );
    }

It's all working well for the date transformation and all...

But the close-on-select parameter doesn't seem to be interpreted. When I select a date or an hour etc... it always close the picker then I have to re-open to select the hour then reopen to select the minute etc...

What am I missing ?

allenhwkim commented 7 years ago

Please use like the following as you see in README.md. The value is string "false", not boolean false. close-on-select="false" or [close-on-select]="'false'"

I treat this case as very exceptional for the convenience, if that one does not satisfy your coding principal(true/false), please make a PR.

TwanoO67 commented 7 years ago

I also tried with this syntaxe but it's not working neither. Or at least, not how I expect it to...

Maybe it's not the option I am looking for, but for the moment, to select a date I have to:

So I supposed, that with the param "close-on-select" to "false", I would be abble to do:

Is that not what the option is for ?

TwanoO67 commented 7 years ago

Ok, the problem was not in your code.

I was handling my own button to open the datepicker, and so on valueChanged, I closed the input myself. The problem was that using the directive, with close-on-select we are unable to know if the valueChanged, or if the valueChanged and the popup was closed. So I added an event to do that, and submitted a PR