Tutorialsplane

angular.merge


angular.merge: This function is used to merge two objects in AngularJs. You can also use this function to merge multiple objects. Here in this tutorial we are going to explain how you can use this function to merge objects in AngularJs. You can use our online editor to edit and run the code online.


angular.merge – AngularJs Merge Objects | Example

Sytax for angular.merge is as below-

Syntax –

angular.merge Syntax

angular.merge(src, dst);

The above function copies the numerable properties from the src(source) object(s) to dst(destination).

Arguments

Returns

Now let us create a simple example to understand the above function.

Example

AngularJs Merge Objects Example




 
 

  
<div ng-app="myApp">  
<div ng-controller="myController">  
    <button ng-click="mergeObjects()">mergeObjects </button>
	<br/>
	Result for a = {{result1}}<br/>
	Result for b = {{result2}}
</div> 
</div>
  
                                                                                                                                                                           

The above example will merge the object b into object a.

If you run the above example it will produce the output something like this –

AngularJs Api Refrence

AngularJs Directive