有人知道为什么深拷贝在我的情况下不起作用,浅拷贝/赋值工作正常:
vm.category = null;
$http.get("/api/category/" + vm.categoryId)
.then(function (response) {
//does not work
angular.copy(response.data, vm.category);
//works just fine
vm.category = response.data;
}, function (error) {
vm.errorMsg = "There was an error retrieving category data: " + error;
});
此深层复制方法可以正常工作:
vm.category = angular.copy(response.data);
为什么:
angular.copy(response.data, vm.category);
不起作用?