@@ -609,6 +609,42 @@ function isLeafNode (node) {
609
609
* @param {(Object|Array)= } destination Destination into which the source is copied. If
610
610
* provided, must be of the same type as `source`.
611
611
* @returns {* } The copy or updated `destination`, if `destination` was specified.
612
+ *
613
+ * @example
614
+ <doc:example>
615
+ <doc:source>
616
+ <div ng-controller="Controller">
617
+ <form novalidate class="simple-form">
618
+ Name: <input type="text" ng-model="user.name" /><br />
619
+ E-mail: <input type="email" ng-model="user.email" /><br />
620
+ Gender: <input type="radio" ng-model="user.gender" value="male" />male
621
+ <input type="radio" ng-model="user.gender" value="female" />female<br />
622
+ <button ng-click="reset()">RESET</button>
623
+ <button ng-click="update(user)">SAVE</button>
624
+ </form>
625
+ <pre>form = {{user | json}}</pre>
626
+ <pre>master = {{master | json}}</pre>
627
+ </div>
628
+
629
+ <script>
630
+ function Controller($scope) {
631
+ $scope.master= {};
632
+
633
+ $scope.update = function(user) {
634
+ // Example with 1 argument
635
+ $scope.master= angular.copy(user);
636
+ };
637
+
638
+ $scope.reset = function() {
639
+ // Example with 2 arguments
640
+ angular.copy($scope.master, $scope.user);
641
+ };
642
+
643
+ $scope.reset();
644
+ }
645
+ </script>
646
+ </doc:source>
647
+ </doc:example>
612
648
*/
613
649
function copy ( source , destination ) {
614
650
if ( isWindow ( source ) || isScope ( source ) ) {
0 commit comments