Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upHow would I use this inside ng-repeat? #155
Comments
|
Cos you are using the same value for IsOpen.... You need to use a different variable for each one |
|
How? I tried the following: <input type="text" class="form-control" datetime-picker="dd-MM-yyyy" ng-model="visitor.birthdate" is-open="picker[[$index]].open" enable-time="false"
save-as="true" datepicker-options="picker[[$index]].datepickerOptions" close-on-date-selection="false" datepicker-append-to-body="false" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="openCalendar($event, 'picker' + $index)"><i class="fa fa-calendar"></i></button>
</span> $scope.picker0 = {};
$scope.openCalendar = function(e, picker) {
console.log(picker);
console.log($scope[picker]);
$scope[picker].open = true;
};Two problems: How can we create something more scalable? It does work when I remove [[$index]] from is-open and datepicker-options and just hardcore it as picker0 for this example. |
|
Why have you wrote |
|
Also, are all your datepickers different?? If not, pass in the same object for each one... If they are, then you need to pass in a different object for each different one |
|
No they are the same for this page. picker[$index].datepickerOptions and picker[$index].isopen does not work either. The index is 0 in this case. When I write picker0.isopen and picker0.datepickerOptions it does work but that's not scalable. |
|
can you create a simple plunkr to replicate and i will have a look |
|
Hah that works perfectly in the plnkr. Cheers! |
When used inside ng-repeat (adding multiple users to a form) clicking on the calender icon the datepicker opens for each user.