Equivalent of angular.equals in angular2

前端 未结 2 2051
走了就别回头了
走了就别回头了 2021-02-11 18:22

I am working on migration of angular 1 project to angular 2 . In angular 1 project I was using angular.equals for object comparison angular.equals($ctrl.obj1, $ctrl.newObj

2条回答
  •  半阙折子戏
    2021-02-11 19:12

    @Günter Yes you are right there is no equivalent in angular2 . While searching more I found third party library lodash which will do same job as angular.equals and syntax is same as angular one and this library solves my problem

    Code example from lodash documentation

    var object = { 'a': 1 };
    var other = { 'a': 1 };
     
    _.isEqual(object, other);
    // => true
     
    object === other;
    // => false
    

提交回复
热议问题