Ngx-bootstrap: [DatePicker] onChange

Created on 27 Jun 2016  路  14Comments  路  Source: valor-software/ngx-bootstrap

Hi,

Is there a way of telling that the date value has changed, ie somebody selected a new date? I'm trying with (change) on the same input as the [(ngModel)]. But that (change) only seems to fire when I manually change the value of that input, instead of using datepicker.
I also tried with (click) on the datepicker, but than of course (click) also fires when somebody select a your or month, without actually changing the date.
Timepicker seems to have (change)="changed()" implemented, but datepicker not.
Thanks for any help.

Most helpful comment

You could separate the property binding and the event. Something like:

<datepicker [ngModel]="dt" (ngModelChange)="onChange($event)"></datepicker>

Then in the event handler you can do whatever you want.

All 14 comments

You could separate the property binding and the event. Something like:

<datepicker [ngModel]="dt" (ngModelChange)="onChange($event)"></datepicker>

Then in the event handler you can do whatever you want.

Thanks adrianfaciu. It works like that. Still, I don't know why the Timepicker has a explicit change event emitter implemented, and Datepicker not. But, it's not so much an issue.

One more thing!
If you want your change detection to update the model, you have to keep banana in a box syntax [(ngModel)]="dt", on top of (ngModelChange)="onChange($event)" to do other stuff you want when the model kets updated.

Having same issue, just inexperienced with typescript. Uploaded my html and typescript so you can see the whole thing. Basically I just want to disable the submit button if one or both of inputs is blank. Issue is that if I manually make one of the inputs blank and then choose a new date from datepicker, the form validation doesn't recognize. I tried both [ngModel] and [(ngModel)]
[hypertml.txt](https://github.com/valor-software/ng2-bootstrap/files/567463/hypertml.txt)
typescript.txt

AN ISSUE WITH THIS...
< /span>
(ngModelChange)="onChange($event)">< /datepicker>

If I do this, clicking the calender icon triggers the onChange event..

Same issue than @somithajoseph If I do this, clicking the calender icon triggers the onChange event..

Same here! As @somithajoseph and @pegaltier.
Is anyone going to address this issue?

Once after inserting into DB the datepicker value is reducing by '1' i.e 2016-02-21 TO 2016-02-20 If i am using ng2-datepicker with ngModelChange....
why i am facing this issue?? any help pls...

@himajaM faced same issue but i fixed using the datepicker data as slicing the Time Data from datepicker data

hi all, i am using ng2-datepicker in my poc kindly let me know event name which would be fire on model change . i tried (change),(onModelChange),(selectedChanged) but these are not working please tell me your help would be grateful.

I'm using ngx timepicker and datepicker for same object property, so using ngModelChange in both will cause infinite calls to callback functions

I want to use the ngx datepicker with formcontrol so, I have taken like this

apbedi picture apbedi on 24 Jun 2019

I want to use the ngx datepicker with formcontrol so, I have taken like this

apbedi picture apbedi on 24 Jun 2019

I'm using ngx-bootstrap datepicker. I want to change daterangepicker into two input fields. when I change date from one field automatically date change in second input field. Anyone tell how I make this event.

Was this page helpful?
0 / 5 - 0 ratings