diff options
| author | Igor Minar | 2010-11-24 17:32:04 -0800 |
|---|---|---|
| committer | Igor Minar | 2010-11-24 17:32:04 -0800 |
| commit | 73194009a9ecc64d7243c1bf5dd6248408fe32c6 (patch) | |
| tree | 53e7b5cc4308441479f143aa9f9173f67d6a3635 /src | |
| parent | 162f41a1abd6ec041ff6cfead605321a554063b1 (diff) | |
| download | angular.js-73194009a9ecc64d7243c1bf5dd6248408fe32c6.tar.bz2 | |
docs for angular.Object.copy
Diffstat (limited to 'src')
| -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) { |
