我正在尝试在模式窗口中实现ng-repeat列表中的datepicker。我尝试了其他选项,例如在ng-model中使用$ parent,object,bracket,但无法解决问题。
我可以打开日期选择器并选择一个日期,但是无法初始化它。
这是我的HTML代码:
<tr ng-repeat="item in items">
<td style="width:50%" class="text-bold">{{::item.id}}</td>
<td style="width:50%">
<div class="inline-flex" uib-tooltip="{{::item.id}}">
<input type="text" uib-datepicker-popup="{{::format}}" ng-model="item.value.id" is-open="popup1.opened" datepicker-options="endDateOptions"
datepicker-append-to-body="false" close-text="Fermer" current-text="Aujourd'hui" clear-text="Effacer" ng-change="valueChanged(item)"/>
<span>
<button ng-attr-id="{{'btn-calendar-'+item.value.id}}" type="button" class="btn btn-default" ng-click="open1()">
<i class="glyphicon glyphicon-calendar"></i>
</button>
</span>
</div>
</td>
</tr>
<tr ng-repeat="item in items">
<td style="width:50%" class="text-bold">{{::item.id}}</td>
<td style="width:50%">
<div class="inline-flex" uib-tooltip="{{::item.id}}">
<input type="text" uib-datepicker-popup="{{::format}}" ng-model="item.value.id" is-open="popup1.opened" datepicker-options="endDateOptions"
datepicker-append-to-body="false" close-text="Fermer" current-text="Aujourd'hui" clear-text="Effacer" ng-change="valueChanged(item)"/>
<span>
<button ng-attr-id="{{'btn-calendar-'+item.value.id}}" type="button" class="btn btn-default" ng-click="open1()">
<i class="glyphicon glyphicon-calendar"></i>
</button>
</span>
</div>
</td>
</tr>
这是我的js代码:
var modalModificationSeuil =
{
backdrop : 'static',
keyboard : true,
size: 'lg',
templateUrl : "templates/modification-threshold/modification.threshold.view.html",
controller : [
'$scope',
'$rootScope',
'$uibModalInstance',
'items',
'parameters',
function($scope, $rootScope, $uibModalInstance, items, parameters)
{
$scope.endDateOptions = {};
$scope.popup1 = { opened: false};
$scope.parameters = parameters;
$scope.disabled=true;
$scope.parametersChanged = new Object();
$scope.statusMessage = {
message : undefined,
isOpen : false,
templateUrl : 'templates/status.message.template.html'
};
var filterChanged = false;
$scope.items = traiterItems(items);
$scope.createDatePickerModel = function(items)
{
for (var a in items)
{
if (items[a].value.editorType == 'DATEPICKER')
{
$scope.datepicker = new Object();
$scope.datepicker[items[a].value.id] = items[a].value._value;
}
}
}
$scope.createDatePickerModel($scope.items);
}
],
resolve:
{
items : function ()
{
return service.items;
},
parameters : function ()
{
return service.parameters;
}
}
};