Reputation: 2703
I want to add an uib-datepicker
in an ng-repeat
. Each item has it own min and maxdate, so I want to conditional set this to the datepicker.
Currently I have this, but it isn't working:
<p class="input-group">
<input class="form-control" type="text" uib-datepicker-popup="dd-MM-yyyy" ng-model="task.datePlanned" is-open="popup.opened" datepicker-options="dateOptions($index)" close-text="Sluiten">
<span class="input-group-btn">
<button class="btn btn-default" type="button" ng-click="openDate()">
<i class="fa fa-calendar"></i>
</button>
</span>
</p>
Controller:
$scope.dateOptions = function(index){
return {
maxDate: new Date($scope.campaign.tasks[index].endDate),
minDate: new Date($scope.campaign.tasks[index].startDate)
}
}
$scope.openDate = function(){
$scope.popup.openend = true;
}
$scope.popup = {
openend: false
}
I get an Error: [$rootScope:infdig]
error at the min
and maxdate
.
Is there a way to add conditional dates to the picker?
Upvotes: 0
Views: 1451
Reputation: 4020
Each item has it own min and maxdate, so I want to conditional set this to the datepicker.
If the requirement is to set a separate min, max for each item, you could expand the object definition in the tag itself, like this:
<p class="input-group">
<input class="form-control" type="text"
uib-datepicker-popup="dd-MM-yyyy"
ng-model="task.datePlanned"
is-open="popup.opened"
datepicker-options="{
maxDate: task.endDate,
minDate: task.startDate
}"
close-text="Sluiten">
<span class="input-group-btn">
<button class="btn btn-default" type="button" ng-click="openDate()">
<i class="fa fa-calendar"></i>
</button>
</span>
</p>
Upvotes: 2