【发布时间】:2016-06-29 06:55:30
【问题描述】:
我用过date time picker。当我将它用作静态时,它工作正常。当我动态添加输入字段时,如何使其工作。 HTML
<div class="form-group" ng-repeat="item in items">
<div class="row" style="margin: 15px 0px;">
<div class="col-md-6 col-lg-6 col-sm-6" style="padding-left:0">
<label>Start Date</label>
<p class="input-group">
<input type="text" class="form-control" datetime-picker="dd/MM/yyyy" enable-time="false" ng-model="item['start_date'+$index]" is-open="['start_date'+$index].open" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="openCalendar($event, 'start_date',$index)"><i class="fa fa-calendar"></i></button>
</span>
</p>
</div>
</div>
</div>
<button ng-click="add()">Add New Row</button>
控制器
$scope.items = [];
$scope.add = function() {
$scope.items.push({
start_date:"",
});
}
$scope.openCalendar = function(e,picker,index) {
console.log('index',index);
console.log('picker',picker);
var picker_index=picker+index;
console.log($scope[picker_index])
$scope.[picker_index]open = true;
console.log( $scope[picker][index])
};
我无法使用 ng-model 和 is-open 属性中的索引值打开特定的日期选择器。因为日期选择器是动态添加的。谁能帮我解决这个问题。
【问题讨论】:
标签: angularjs dynamic datepicker angular-bootstrap