0
我有一个表,我可以编辑。但是,如果我使用分页更改页面,编辑后的值将被删除。我尝试在更改页面时调用我的保存功能,但那不起作用。
我有一个表是这样的:保存更改分页不起作用。值不保存
...
<table>
...
<th>
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-show="!valueForm.$visible" ng-click="valueForm.$show()">
Edit
</button>
</span>
</div>
<form editable-form name="valueForm" onaftersave="$ctrl.saveColumn('valueTranlate')" ng-show="valueForm.$visible">
<button type="submit" ng-disabled="valueForm.$waiting" class="btn btn-primary">
Save
</button>
<button type="button" ng-disabled="valueForm.$waiting" ng-click="valueForm.$cancel()" class="btn btn-default">
Cancel
</button>
</form>
</th>
...
<tr dir-paginate="v in my array>
...
</table>
<dir-pagination-controls auto-hide="false" on-page-change="$ctrl.saveColumn()" boundary-links="true" max-size='7'></dir-pagination-controls>
...
my .js
saveColumn() {
if (this.$scope.valueForm.$visible) {
angular.forEach(this.langV, (value) => {
this.$http.patch('/api/dict_values/' + value.v_id, {
id: value.v_id,
value: value.value2,
user_id: this.currentUser()._id,
key_id: value._id,
lang_id: this.$scope.select2
});
});
this.showLang(this.$scope.select1, this.$scope.select2);
}
}
所以调用saveColumn()
它遍历每个页面上的所有字段和保存价值,而不是其他页面的编辑,因为是“删除”。尝试在页面更改时调用save()
,但值比save()
“删除”更快。
那么我怎样才能实现我可以在每一页上编辑,如果我改变页面的值不会被遗忘?