DanielYKPan/date-time-picker

minMoment & maxMoment are not updated

Closed this issue · 6 comments

Hi,

I have two inputs beginDate and endDate.

I'm using minMoment & maxMoment with date type by example:

private minDate: Date; private maxDate: Date;

In my constructor, I set the actual date for the minimum and for the maximum the actual date plus 3 years.

I also need to change the minimum and maximum according to the second input.

I notice that the minMoment and maxMoment are never updated when you change it locally.
Once you have selected a date, if you want to go back to this picker, you select the picker, you will see that the min and max is the same as before, but he is supposed to change.

My minDate and maxDate can change but in the picker no.

Is there a way to fix it?

Have a great day.

Mickael

I has been fixed.
Update to the latest version. And see all those changes in README.md

@DanielYKPan @MickaelRomaniello How exactly did it get fixed? I encounter the exact same situation, my endDate should be 2 minutes after my beginDate, the min of the endDate does not update on beginDate changes.. Can you please provide an example showing what it is fixed and how to use it? Thanks!

@kesemdavid
Could you provide a git repo to demonstrate the issue?

@DanielYKPan I don't actually have one but ill provide the relevant code:

html:

<span class="field-name">Starting Time:</span>
<input name="startingTime"
       class="date-input"
       [value]="startingTime"
       [mode]="'inline'"
       [minMoment]="minStartingTime.format('YYYY-MM-DD')"
       [returnObject]="'moment'"
       [(ngModel)]="startingTime"
       (ngModelChange)="calculateMinEndingTime()"
       dateTimePicker
       required/>
</div>

<span class="field-name">Ending Time:</span>
<input name="endingTime"
       class="date-input"
       [value]="endingTime"
       [mode]="'inline'"
       [minMoment]="formattedNinEndingTime"
       [returnObject]="'moment'"
       [(ngModel)]="endingTime"
       dateTimePicker
       required/>

component

  public calculateMinEndingTime() {
    this.minEndingTime = moment(this.startingTime);
    this.minEndingTime.add(2, 'm');
    this.formattedNinEndingTime = this.minEndingTime.format('YYYY-MM-DD')
  }

As you can see, as the startingTime changes the calculateMinEndingTime triggers to add 2 minutes to that startingTime and set it as the minEndingTime, unfortunately, it never changes in the view

Thanks in advance for the help :)

@kesemdavid
Update the package to ^4.3.4, and it should be all right

PS: If you add 2 minutes, you may consider to format the minEndingTime to 'YYYY-MM-DD HH:mm'.
Cheers

@DanielYKPan
Thanks! I've updated the package and the minEnding now updates on startingTime chane

The 'YYYY-MM-DD HH:mm' does not seem to work though, the minMoment attribute seems to totally ignore the given string with that format, so it doesnt disable any dates
Any ideas?