Compare objects in Angular

前端 未结 4 1630
情歌与酒
情歌与酒 2020-12-04 13:59

Is it possible to do a \"deep\" comparison of two object in Angular? What I would like to do is compare each key/value pair. For example:

Object 1

{
         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 14:41

    Bit late on this thread. angular.equals does deep check, however does anyone know that why its behave differently if one of the member contain "$" in prefix ?

    You can try this Demo with following input

    var obj3 = {}
    obj3.a=  "b";
    obj3.b={};
    obj3.b.$c =true;
    
    var obj4 = {}
    obj4.a=  "b";
    obj4.b={};
    obj4.b.$c =true;
    
    angular.equals(obj3,obj4);
    

提交回复
热议问题