katemihalikova / ion-datetime-picker

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

Any way to set a calculated max date using between? #52

Closed bfalzarano closed 7 years ago

bfalzarano commented 7 years ago

Hi,

using between how can I set a calculated max date ($scope.maxDate calculated and set in the controller) for the final value? 'final': 'maxDate' or 'final': '{{maxDate}}' is not working.

e.g. <div class='item' ion-datetime-picker am-pm only-valid="{'between': {'initial': 'today', 'final': 'maxDate'}, 'inclusive': true}" title="'From Date/Time'" ng-model="event.fromDate">

controller.js

//maxDate set to 180 days from today
  $scope.maxDate = new Date(new Date().setDate(new Date().getDate()+180));
bfalzarano commented 7 years ago

ok so this appears to work : )

<div class='item' ion-datetime-picker am-pm only-valid="{'between': {'initial': 'today', 'final': maxDate}, 'inclusive': true}" title="'From Date/Time'" ng-model="event.fromDate">

controller.js

//maxDate set to 180 days from today
  $scope.maxDate = new Date(new Date().setDate(new Date().getDate()+180));
katemihalikova commented 7 years ago

Hi, sure, you have to use valid javascript/angular expression there, including the "variable reference". I'm glad you worked it out yourself :)