Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="myApp">
<head>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
  <meta charset="utf-8">
  <title>AngularJS copy() and extend() method Example</title>
</head>
<body ng-controller="MyController" ng-cloak>
  <h1>Angular copy and extend method Example</h1>
  
  <h3>$scope.fruitArrayDestination</h3>
  <ol>
     <li ng-repeat="item in fruitArrayDestination">
       {{item}}
     </li>
   </ol>
  <h3>$scope.subjectObjectDestination with extend()</h3>
  {{subjectObjectDestination | json}}
</body>
</html>
 
var myApp= angular.module("myApp",[]);
myApp.controller("MyController",
  ["$scope", function($scope){
    $scope.fruitArraySource =["Mango","Apple"];
    $scope.fruitArrayDestination =["Orange","Grapes"];
    angular.copy($scope.fruitArraySource, $scope.fruitArrayDestination);
    
    $scope.studentObjectSource ={"name":"Sandeep"};
    $scope.subjectObjectDestination ={"subject":"computer"};
     angular.extend($scope.subjectObjectDestination,
                         $scope.studentObjectSource);
}]);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
saan1984pro
0viewers