angular-extend-1

 

angular.extend creates a shallow copy of one or more sources object provided to destination object. In this example three objects students, student1 and student2 source object students and dest as destination object. See the code snippet:

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome in the AngularJS</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="extendController"> <div ng-repeat="extStudent in dest"> {{extStudent.name}} </div> </div> <script> var app = angular.module("app", []); app.controller('extendController', ['$scope', function ($scope) { $scope.students = [{ name: 'Herry', id: 1 }, { name: 'John', id: 2 }, { name: 'Peter', id: 3 }]; $scope.students1 = [{ name: "test", cls: "MCA" }]; $scope.students2 = [{ name: 'A', id: 1 }, { name: 'B', id: 2 }, { name: 'C', id: 3 }]; $scope.dest = {}; angular.extend($scope.dest, $scope.students, $scope.students1, $scope.students2); }]); </script> </body> </html>
Output