Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有人可以向我解释为什么我可以让 angular.copy 使用对象或数组,但是如果我尝试使用布尔值,它就不起作用。
$scope.data = {}; $scope.data.booleanVal = false; angular.copy(true, $scope.data.booleanVal); alert($scope.data.booleanVal);
适当的 JSFiddle 链接。
http://jsfiddle.net/IgorMinar/ADukg/embedded/result/
指示明确指出:
创建源的深层副本,它应该是一个对象或数组。
参考:http ://docs.angularjs.org/api/angular.copy