forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.Object.copy.html
38 lines (32 loc) · 1.95 KB
/
angular.Object.copy.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<h1>angular.Object.copy</h1>
<fieldset class="workInProgress"><legend>Work in Progress</legend>
This page is currently being revised. It might be incomplete or contain inaccuracies.</fieldset>
<h2>Description</h2>
<p>Creates a deep copy of <code>source</code>.</p>
<p>If <code>destination</code> is not provided and <code>source</code> is an object or an array, a copy is created &
returned, otherwise the <code>source</code> is returned.</p>
<p>If <code>destination</code> is provided, all of its properties will be deleted.</p>
<p>If <code>source</code> is an object or an array, all of its members will be copied into the <code>destination</code>
object.</p>
<p>Note: this function is used to augment the Object type in angular expressions. See
<a href="#!angular.Object"><code>angular.Object</code></a> for more info.</p><h2>Usage</h2>
<div ng:non-bindable=""><pre class="brush: js; html-script: true;">angular.Object.copy(source, destination);</pre>
</div>
<h3>Parameters</h3>
<ul class="parameters"><li><code ng:non-bindable="">source – {*} – </code>
The source to be used to make a copy.
Can be any type including primitives, <code>null</code> and <code>undefined</code>.</li>
<li><code ng:non-bindable="">destination<i>(optional)</i> – {(Object|Array)} – </code>
Optional destination into which the source is copied.</li>
</ul>
<h3>Returns</h3>
<code ng:non-bindable="">*</code>
– The copy or updated <code>destination</code> if <code>destination</code> was specified.<h2>Example</h2>
<doc:example><doc:source>Salutation: <input type="text" name="master.salutation" value="Hello" /><br/>
Name: <input type="text" name="master.name" value="world"/><br/>
<button ng:click="form = master.$copy()">copy</button>
<hr/>
Master is <span ng:hide="master.$equals(form)">NOT</span> same as form.
<pre>master={{master}}</pre>
<pre>form={{form}}</pre></doc:source>
</doc:example>