AngularJS equal比较对象实例详解
使用情况
1首先,所有满足a===3这种的对象,在angular.equals(a,b)中都会返回真
2所有对象的类型,以及属性值都相同的,也会返回真
3NaN和NaN也会返回真(在javascript中,返回的是假)
4正则也会返回真(在javascirpt,/abc//abc/被认为是不相等的)
样例
<html> <head> <metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/> <scriptsrc="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script> </head> <bodyng-app="myApp"> <divng-controller="myCtrl"> {{a_equals}} {{user_equals}} {{nan_equals}} {{reg_equals}} </div> <scripttype="text/javascript"> angular.module("myApp",[]) .controller("myCtrl",function($scope){ vara=3; $scope.a_equals=angular.equals(a,3);//a===3 varuser1={"name":"xing","age":30}; varuser2={"name":"xing","age":30}; $scope.user_equals=angular.equals(user1,user2); $scope.nan_equals=angular.equals(NaN,NaN);//injavascirptisfalse $scope.reg_equals=angular.equals(/abc/,/abc/);//injavascriptisfalse }); </script> </body> </html>
运行会得到四个true
以上就是对AngularJSequal比较对象做的详细介绍,后续继续整理相关资料,谢谢大家对本站的支持!