Closed maheshwarishivam closed 7 years ago
Hi there, sure it is possible. Could you share what you have done so far via codepen/plnkr/jsfiddle/whatever?
I'm trying to do the following:
In my controller:
$scope.visitDate = new Date();
$scope.closureDate = new Date();
In my view template:
<!-- Visit Date Start -->
<ion-item>
<span class="label">Visit Date</span>
<div class="item-note dark datepicker" ion-datetime-picker date monday-first ng-model="visitDate">
{{visitDate | date: "YYYY-MM-DD"}}
</div>
<small class="positive">(YYYY-MM-DD)</small>
</ion-item>
<!-- Visit Date End -->
<!-- Closure Date Start -->
<ion-item>
<span class="label">Closure Date</span>
<div class="item-note dark datepicker" ion-datetime-picker date monday-first ng-model="closureDate" only-valid="{'after': '{{visitDate}}', 'inclusive': true}">
{{closureDate | date: "YYYY-MM-DD"}}
</div>
</ion-item>
<!-- Closure Date End -->
Now, what I want it the only-after
validation in the closureDate
gets updated as soon as user selects a visitDate
, but that doesn't seem to update. It stays a today's date only.
I hope that the confusion is clear.
See codepen.
The restriction is updated as expected if you use only-valid="{'after': visitDate, 'inclusive': true}"
- the attr is ordinary javascript object.
The second step would be to use ¨ng-change` on the first picker to check if the value of the second picker needs to be adjusted.
It does not work for me.
Here's what I did:
visitDate
.closureDate
.today
are disabled in closureDate
Sorry, seems like a wrong version of the codepen was saved before (the one with 'after': '{{visitDate}}'
), try it now.
Is there a possibility to set the
only-valid
restrictions using a scope variable such that when the value of the variable changes, the restrictions also get updated.