English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Detailed explanation of AngularJs equal comparison object instance

Usage

1 Firstly, all that satisfy a === 3 Such objects will all return true in angular.equals(a,b)
2 All objects with the same type, as well as properties and values, will return true
3 NaN and NaN will also return true (in JavaScript, it returns false)
4 Regular expressions will also return true (in javascirpt,/abc/ /abc/is considered not equal)

Example

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script>
</head>
<body ng-app="myApp">
  <div ng-controller="myCtrl">
    {{ a_equals }}
    {{ user_equals }}
    {{ nan_equals }}
    {{ reg_equals }}
  </div>
  <script type="text/javascript">
  angular.module("myApp",[])
  .controller("myCtrl",function($scope){
    var a = 3;
    $scope.a_equals = angular.equals(a,3);//a === 3
    var user1 = {"name":"xing","age":30};
    var user2 = {"name":"xing","age":30};
    $scope.user_equals = angular.equals(user1,user2);
    $scope.nan_equals = angular.equals(NaN,NaN);//in javascirpt is false
    $scope.reg_equals = angular.equals(/abc/,/abc/);// in javascript is false
  });
  </script>
</body>
</html>

Running will get four true

This is the detailed introduction of AngularJS equal comparison object, we will continue to sort out relevant materials in the future, thank you all for your support to this site!

Declaration: The content of this article is from the Internet, the copyright belongs to the original author, the content is contributed and uploaded by Internet users spontaneously, this website does not own the copyright, does not undergo manual editing, and does not assume relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (Please replace # with @ when sending an email to report abuse, and provide relevant evidence. Once verified, this site will immediately delete the infringing content.)

You May Also Like