25 lines
2.4 KiB
HTML
Executable file
25 lines
2.4 KiB
HTML
Executable file
<a href="http://github.com/angular/angular.js/tree/v1.2.0rc1/src/Angular.js#L590" class="view-source btn btn-action"><i class="icon-zoom-in"> </i> View source</a><a href="http://github.com/angular/angular.js/edit/master/src/Angular.js" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">angular.copy</code>
|
|
<div><span class="hint">API in module <code ng:non-bindable="">ng</code>
|
|
</span>
|
|
</div>
|
|
</h1>
|
|
<div><h2 id="Description">Description</h2>
|
|
<div class="description"><div class="angular-copy-page"><p>Creates a deep copy of <code>source</code>, which should be an object or an array.</p>
|
|
<ul>
|
|
<li>If no destination is supplied, a copy of the object or array is created.</li>
|
|
<li>If a destination is provided, all of its elements (for array) or properties (for objects)
|
|
are deleted and then all elements/properties from the source are copied to it.</li>
|
|
<li>If <code>source</code> is not an object or array, <code>source</code> is returned.</li>
|
|
</ul>
|
|
<p>Note: this function is used to augment the Object type in Angular expressions. See
|
|
<a href="api/ng.$filter"><code>ng.$filter</code></a> for more information about Angular arrays.</p>
|
|
</div></div>
|
|
<h2 id="Usage">Usage</h2>
|
|
<div class="usage"><pre class="prettyprint linenums">angular.copy(source[, destination]);</pre>
|
|
<h4 id="parameters">Parameters</h4><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>source</td><td><a href="" class="label type-hint type-hint-object">*</a></td><td><div class="angular-copy-page"><p>The source that will be used to make a copy.
|
|
Can be any type, including primitives, <code>null</code>, and <code>undefined</code>.</p>
|
|
</div></td></tr><tr><td>destination <div><em>(optional)</em></div></td><td><a href="" class="label type-hint type-hint-object">Object</a><a href="" class="label type-hint type-hint-array">Array</a></td><td><div class="angular-copy-page"><p>Destination into which the source is copied. If
|
|
provided, must be of the same type as <code>source</code>.</p>
|
|
</div></td></tr></tbody></table><h4 id="returns">Returns</h4><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-object">*</a></td><td><div class="angular-copy-page"><p>The copy or updated <code>destination</code>, if <code>destination</code> was specified.</p>
|
|
</div></td></tr></table></div>
|
|
</div>
|