<tr ng-repeat="week in weeks">
<!-- content for every week with occupancy-array -->
</tr>
在此表中,我为占用阵列实施了第二次ng-repeat,每周结构如下:
Array[WeekId] = {early: null, late: null, night: null}
因此,对于3周,该对象存在3次。
对象应该可以通过输入字段每周操作。 所以我的HTML是:
<tr ng-repeat="week in weeks">
<td ng-repeat="(title, value) in occupancies[week.id]">
<input class="form-control" ng-model="value"/>
</td>
</tr>
但是在这种情况下,我通过达到新值来解决问题,因为数组的范围不会改变。
然后我决定将我的第二次重复改为:
<td><input class="form-control" ng-model="occupancies[week.id].early"/></td>
<td><input class="form-control" ng-model="occupancies[week.id].late"/></td>
<td><input class="form-control" ng-model="occupancies[week.id].night"/></td>
现在,范围将会改变,但问题是,我的占用阵列中的对象是镜像的。这意味着通过改变入住率 - 在第1周的早期将改变入住率 - 在其他周的早期也是如此。
我需要帮助!
答案 0 :(得分:0)
我认为您可以尝试将对象分配给占用者并重试。
$scope.occupancies = {};