我有下面的angular代码来初始化angular表单。它返回一个几乎为空的记录,除了几个日期和员工信息。
我试图创建一个范围变量,以便在填写表单后保留原始记录以进行比较。这就是$scope.TechSheetInfoStatic的用途。
出于我们在这里的目的,我将$scope.TechSheetInfo.Customer.Email设置为一个虚拟值。在更新$scope.TechSheetInfo时,
还更新了$scope.TechSheetInfoStatic
. 为什么?
$scope.initializeTechSheet = function() {
$scope.TechSheetInfo = [];
$scope.TechSheetInfoStatic = [];
$scope.customerIDDisabled = false;
$scope.orderIDDisabled = false;
const successFunction = function(response) {
$scope.TechSheetInfo = response.data;
$rootScope.customerInfo = response.data.Customer;
$scope.TechSheetInfoStatic = response.data;
$scope.TechSheetInfo.Customer.Email = "bobo@bobo.com";
alert(JSON.stringify($scope.TechSheetInfo.Customer));
alert(JSON.stringify($scope.TechSheetInfoStatic.Customer));
};
const failureFunction = function(response) {
//console.log('Error' + response.status);
};
TechSheetFactory.ITS(successFunction, failureFunction);
};