表格编辑表格点击
问题描述:
我是AngularJS的新手,我试图编辑表格数据。我不想使用网格编辑器,因为符合508(和客户端首选项)。首选的功能是点击一行,并用行数据填充表单。表格编辑表格点击
我遇到的问题是当我编辑表格中的数据时,它会自动更新表格数据。我为表数据和表单数据分开了$ scope变量,所以我很困惑为什么会发生这种情况。这会导致所有编辑自动保存。请参阅下面的jsfiddle,了解我的问题简化表。
忽略代码,只需在如此如此不抱怨的jsfiddle链接,所有的代码是的jsfiddle
$scope.editData = function (rowId) {
'use strict';
$scope.currentEditId = rowId;
$scope.managementBaselineEdit = $scope.formData.managementBaseline.operations[rowId];
}
答
您可以通过选择对象即副本避免的行为:
$scope.managementBaselineEdit = angular.copy($scope.formData.managementBaseline.operations[rowId]);
请看这里工作演示
感谢您使用JSFiddle。 – JabberwockyDecompiler 2015-02-05 22:39:10