Ionic2 Model updating after click

So im not exactly sure how to word this issue. I have an inline datepicker component

<datepicker [(ngModel)]="dt" (click)="calculate()">

Things appear to work correctly but…


The dt is updating on click like it should, the datepicker works flawlessly, but the calculate function appears to be getting the value of dt before it has changed. So if the 24th is clicked and then the user clicks on the 25th the calculate function is receiving an input of the 24th

What did I do wrong?

can you show us your calculate function and datepicker component code?

Sorry about that. The date picker component is from ng2-bootstrap (

as for my calculate function, it is just comparing the two dates and calculating what shift someone will be on.

function calculate() {
  var oneDay = 24*60*60*1000;
   .... variable declaration stuff ....

   refDate = new Date("1/1/2013")
   inputDate = dt;

   diff = (inputDate.valueOf - refDate.valueOf) % 35;
   if(diff < 7) { shift = 1}
   if(diff > 7 && diff < 18) {shift = 2}
   if(diff > 20 && diff < 27) { shift = 3}
  else{ shift = 0}

So basically I need my calculate function to wait until the directive has finished updating. I just don’t know how to do that.

Maybe you can use an Promise, so you create two function. One calculate function, which return the promise when calculated.
And then in another function you call the promise function, and in the .then you update the value.

Sorry for my bad English, I hope you understand me.