当页面加载时,$ scope是新鲜和干净的。我想存储新的状态,当用户单击重置按钮时,它会将$ scope重置为加载页面时的状态。下面的代码不起作用,但是与我想要发生的一致。如何存储原始$ scope,然后在$ scope更改后重置它?
(function () {
//function that fires when button is clicked
$scope.resetScope = function () {
$scope = freshScope;
}
//$scope is stored on page load
freshScope = $scope;
});