简体   繁体   English

无法在嵌套的角度ng-repeat中绑定矩js datepicker

[英]Can't bind moment js datepicker inside a nested angular ng-repeat

i tried the following code to bind moment js datepicker inside angular ng-repeat text box.but it not working any one have a solution for this problem kindly give me 我试过下面的代码在角ng-repeat文本框内绑定矩js datepicker。但是任何人都无法解决这个问题,请给我

 angular.forEach(a, function(value, key) { debugger; angular.forEach(value.manageSampleBOList, function(value1, key2) { // var isoDate = new Date(value1.ColectedDate).toISOString(); // var e = moment(value1.ColectedDate); var date = new Date(value1.ColectedDate); var e = toUTCDate(new Date(value1.ColectedDate)); // var now_utc = new Date(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate(), e.getUTCHours(), e.getUTCMinutes(), e.getUTCSeconds()); //var e = moment(value1.ColectedDate); value.manageSampleBOList[key2].ColectedDate = e; //value.manageSampleBOList[key2].momentDate = moment(value1.ColectedDate); }); 
 <tr ng-repeat="TestName in ManageSampl.manageSampleBOList"> <td>{{$index+1}}</td> <td><input type="checkbox" ng-model="TestName.Selected"></td> <td>{{TestName.AnalyteName}}({{TestName.OrderCode}})</td> <td> <input class="form-control" placeholder="Select a Date Time..." moment-picker="TestName.ColectedDate" locale={{Locale}} ng-model="TestName.ColectedDate" ng-model-options="{ updateOn: 'blur' }"> </td> </tr> 

You can use angular repeat index to assign unique id to controls. 您可以使用角度重复索引为控件分配唯一的ID。 like 喜欢

<input id="{{'listDates_' + $index}}" class="input-group-sm" moment-picker 
ng-model="listItem.inputDate"                                                                                     
locale="en" ng-model-options="{ updateOn: 'blur' }" />

then you can get the value in your JS like, 那么您可以像这样在JS中获取值,

for (var i = 0; i < $scope.myList.length; i++)
{
   $scope.myModel.inputDate[i] = $scope.myList.inputDate;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM