katemihalikova / ion-datetime-picker

Date and/or time picker for awesome Ionic framework
MIT License
169 stars 101 forks source link

only-valid 'before' doesn't work dynamically with scope variables #98

Closed blueskiedmorning closed 7 years ago

blueskiedmorning commented 7 years ago

Following up from issue 93 where two pickers are used to select a range of dates.

Using only-valid="{'after': visitDate, 'inclusive': true}" will limit the 2nd picker to after the first picked date. However using the only-valid 'before' argument on the 1st picker doesn't work in the same way.

<div ng-app="demo">
    <ion-header-bar class="bar-positive">
        <h2 class="title">ion-datetime-picker demo</h2>
    </ion-header-bar>
    <ion-content>
        <div class="list">
            <div class="item" ion-datetime-picker date monday-first ng-model="visitDate" only-valid="{'before': closureDate, 'inclusive': true}">
                Visit Date:
                <strong>{{visitDate | date: "yyyy-MM-dd"}}</strong>
            </div>
            <div class="item" ion-datetime-picker date monday-first ng-model="closureDate" only-valid="{'after': visitDate, 'inclusive': true}">
                Closure Date:
                <strong>{{closureDate | date: "yyyy-MM-dd"}}</strong>
            </div>
        </div>
    </ion-content>
</div>

edit: using 'between' eg. only-valid="{'between':{'initial':'01-01-2017', 'final':closureDate} works though, so it seems only 'before' doesn't.

katemihalikova commented 7 years ago

Thanks for reporting this. The bug fixed in v0.4.1 (13a05cc) was introduced again in v0.5.0 (c86dbae). It was again fixed now (7c2b413) and released as v0.5.1.