AngularJS angular.equals() Function (original) (raw)
Last Updated : 01 Aug, 2022
The angular.equals() Function in AngularJS is used to compare two objects or two values whether these are the same or not. If the two values are the same, it returns TRUE else it will return FALSE. The angular.equals() Function supports value types, regular expressions, arrays and objects.
Syntax:
angular.equals(val1, val2);
Parameter value:
- val1 & val2: It specifies the values or the objects that is to be compared.
Return Value: Returns a boolean value ie either TRUE or FALSE.
Example 1: This example illustrates the implementation of the angular.equals() Function in AngularJS, by comparing the values.
HTML `
angular.equals()GeeksforGeeks
angular.equals()
Input B:
{{msg}}
`
Output:
Example 2: This example illustrates the implementation of the angular.equals() Function in AngularJS, by verifying its value type to authenticate the password.
HTML `
angular.equals()GeeksforGeeks
angular.equals()
Confirm Password:
Password matched
<p ng-hide="isMatch || PASS==null"
style="color:red">
Password does not match
</p>
</div>
<script>
var app = angular.module("app", []);
app.controller('geek', ['$scope', function($scope) {
$scope.match = function() {
$scope.isMatch = angular.equals(
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>s</mi><mi>c</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi mathvariant="normal">.</mi><mi>p</mi><mi>a</mi><mi>s</mi><mi>s</mi><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">scope.pass, </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">sco</span><span class="mord mathnormal">p</span><span class="mord mathnormal">e</span><span class="mord">.</span><span class="mord mathnormal">p</span><span class="mord mathnormal">a</span><span class="mord mathnormal">ss</span><span class="mpunct">,</span></span></span></span>scope.PASS);
}
}]);
</script>
`
Output: