尝试使用ng-repeat将数据填充到可编辑的表格数据时,我遇到了这个问题。
以下是我更新的代码:
<table>
<tr style="white-space: nowrap">
<td ng-repeat="assignment in vm.assignments" class="text-center">
<span>
{{ assignment.name }}
</span>
<form editable-form name="{{assignment.name}}" ng-show="{{assignment.name}}.$visible">
<button type="submit" ng-disabled="{{assignment.name}}.$waiting">
save
</button>
<button type="button" ng-disabled="{{assignment.name}}.$waiting"
ng-click="$eval(assignment.name).$cancel()">
cancel
</button>
</form>
<a ng-show="!{{assignment.name}}.$visible" ng-click="$eval(assignment.name).$show()">
edit
</a>
</td>
</tr>
<tr ng-repeat="assignment in vm.assignments">
<td ng-repeat="grade in assignment.grades" class="text-center">
<span editable-text="grade.score" e-name="{{ grade.aname }}" e-form="{{grade.aname}}">
{{ grade.score || '-' }}
</span>
</td>
</tr>
</table>
JS
Assignment.GetAssignmentsByClassId(classId).then(function (data) {
vm.assignments = data;
vm.givenAssignments = _.filter(vm.assignments, { 'given': true });
});
呈现HTML
<span editable-text="grade.score" e-name="research" e-form="research" class="ng-scope ng-binding editable">
90
</span>