©
Dieses Dokument verwendetPHP-Handbuch für chinesische WebsitesFreigeben
创建source的深度复制,可以为一个对象或一个数组。
source不是一个对象或数组(包括null和undefined),返回source。source等于'destination',将抛出一个错误。angular.copy(source,[destination]);
| 参数 | 类型 | 详述 |
|---|---|---|
| source | * | 用于复制的源。可以为任何类型,包括基础类型、 |
| destination
(可选)
|
ObjectArray | 存储复制后的目标。如果提供,必须和 |
| * | 副本或更新后的 |
ng-controller="ExampleController">form = {{user | json}}master = {{master | json}}angular.module('copyExample').controller('ExampleController',['$scope',Function($scope){$scope.master={};$scope.update=Function(user){// Example with 1 argument$scope.master=angular.copy(user);};$scope.reset=Function(){// Example with 2 argumentsangular.copy($scope.master,$scope.user);};$scope.reset();}]);