diff options
| -rw-r--r-- | src/Angular.js | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/Angular.js b/src/Angular.js index 311be0ca..fb23e1f2 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -735,19 +735,40 @@ function isLeafNode (node) { } /** - * Copies stuff. + * @workInProgress + * @ngdoc function + * @name angular.Object.copy + * @function + * + * @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 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 + * {@link angular.Object} for more info. * - * If destination is provided, all of its properties will be deleted and if source is an object or - * an array, all of its members will be copied into the destination object. Finally the destination - * is returned just for kicks. + * @param {*} source The source to be used to make a copy. + * Can be any type including primitives, `null` and `undefined`. + * @param {(Object|Array)=} destination Optional destination into which the source is copied. + * @returns {*} The copy or updated `destination` if `destination` was specified. * - * @param {*} source The source to be used during copy. - * Can be any type including primitives, null and undefined. - * @param {(Object|Array)=} destination Optional destination into which the source is copied - * @returns {*} + * @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> */ function copy(source, destination){ if (!destination) { |
