angular.Object.copy

Work in Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

Description

Creates a deep copy of source.

If destination is not provided and source is an object or an array, a copy is created & returned, otherwise the source is returned.

If destination is provided, all of its properties will be deleted.

If source is an object or an array, all of its members will be copied into the destination object.

Note: this function is used to augment the Object type in angular expressions. See angular.Object for more info.

Usage

angular.Object.copy(source, destination);

Parameters

Returns

* – The copy or updated destination if destination was specified.

Example

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>