Reputation: 3390
I am new to AngularJS and I am attempting to edit table data. I do not want to use a grid editor due to 508 compliance (and client preference). The preferred functionality is to click on a row and a form is populated with the row data.
The problem that I am having is when I edit data in the form it automatically updates the table data. I have separate $scope variables for the table data and the form data so I am confused as to why this is happening. This is causing all edits to automatically be saved. See below for a jsfiddle with a simplified table of my issue.
Ignore code, just in so SO does not complain about JSFiddle link, all code is in JSFiddle
$scope.editData = function (rowId) {
'use strict';
$scope.currentEditId = rowId;
$scope.managementBaselineEdit = $scope.formData.managementBaseline.operations[rowId];
}
Upvotes: 0
Views: 1106
Reputation: 16508
You can avoid that behaviour by making a copy of selected object ie:
$scope.managementBaselineEdit = angular.copy($scope.formData.managementBaseline.operations[rowId]);
please see working demo here
Upvotes: 1