Determines if two objects or two values are equivalent. Supports value types, regular expressions, arrays and objects.
Two objects or values are considered equivalent if at least one of the following is true:
===
comparison.angular.equals
.During a property comparison, properties of function
type and properties with names
that begin with $
are ignored.
Scope and DOMWindow objects are being compared only by identify (===
).
angular.equals(o1, o2);
Param | Type | Details |
---|---|---|
o1 | * |
Object or value to compare. |
o2 | * |
Object or value to compare. |
boolean | True if arguments are equal. |
<div ng-controller="ExampleController">
<form novalidate>
<h3>User 1</h3>
Name: <input type="text" ng-model="user1.name">
Age: <input type="number" ng-model="user1.age">
<h3>User 2</h3>
Name: <input type="text" ng-model="user2.name">
Age: <input type="number" ng-model="user2.age">
<div>
<br/>
<input type="button" value="Compare" ng-click="compare()">
</div>
User 1: <pre>{{user1 | json}}</pre>
User 2: <pre>{{user2 | json}}</pre>
Equal: <pre>{{result}}</pre>
</form>
</div>