如何从$index库中检验值。假设在textboxStart索引和TextboxEnd中。当用户输入起始索引5和结束索引10时,复选框自动选中,从5到10索引。请帮帮我
<tr ng-repeat="item in MyList">
<td>{{$index}}</td>
<td>
<label class="mdl-checkbox mdl-js-checkbox" for="checkbox33">
<input autocomplete="off" ng-model="item.checked"
type="checkbox" id="checkbox33"
class="mdl-checkbox__input" unchecked>
{{CheckItems()}}
</label>
<td>{{item.Name}}</td>
<td>{{item.PilgrimID}}</td>
<td>{{item.GroupName}}</td>
<td>{{item.PassportNo}}</td>
<td>{{item.Gender}}</td>
<td>{{item.SubAgentName}}</td>

发布于 2018-10-10 22:48:58
使用ng-change指令指定更新函数:
<div>Input Start
<input ng-model="inputStart" ng-change="updateSelections(inputStart,inputEnd)" />
</div>
<div>Input End
<input ng-model="inputEnd" ng-change="updateSelections(inputStart,inputEnd)" />
</div>然后更新选择:
$scope.updateSelections = function(iStart, iEnd) {
$scope.MyList.forEach((x,index)=>item.checked = (iStart<=index && index<=iEnd));
};发布于 2018-10-10 07:56:48
你可以通过在你的ItemList模型中添加一个像ItemIndex这样的属性来做到这一点,通过将输入框设置为display none,你可以在ItemList中获得索引值,并且可以从Javascript端做你想做的事情。
<td><input type="text" style="display:none;" ng-model="item.ItemIndex"
ng-value="$index"/>{{$index}}
</td>发布于 2018-10-10 11:06:10
只需将所选值推送到数组中,就像ng-checked="selectedItemIndexes.includes($index)"一样使用selectedItemIndexes
https://stackoverflow.com/questions/52730343
复制相似问题