The doc document for angular.equals() says:
Two objects or values โโare considered equivalent if at least one of the following is true:
Both objects or values โโare compared ===.
Both objects or values โโare of the same type, and all their properties are equal, comparing them with angular.equals.
Both values โโare NaN. (In JavaScript, NaN ==> NaN => false, but we consider two NaN equal)
Both values โโrepresent the same regular expression (In JavasScript, / abc / == / abc / => false, but we consider two regular expressions equal when their textual representation matches).
So, if you get false for .equals() , then we can conclude the following:
- Both are not the same object, so they do not pass
=== - Both values โโare not NaN (you still work with objects)
- Both values โโare not the same regular expression
So, this leaves only the 2nd element in the documentation, which means that either the objects are not of the same type, or some of their properties do not match. So that someone could help you in the future, what exactly between them, we will need to see the actual objects or the code that creates them.
If you have a non-minimized version of angular installed on your page, you can also just make your call to angular.equals() and see which step in the code it finds the difference.
Or, if there are many properties or many objects, so the complexity of the debugger is difficult, you can write your own little debugging procedure to tell you which property was different. It will look something like this:
function compareObjects(s, t) { if (typeof s !== typeof t) { console.log("two objects not the same type"); return; } if (typeof s !== "object") { console.log('arguments are not typeof === "object"'); return; } for (var prop in s) { if (s.hasOwnProperty(prop)) { if (t.hasOwnProperty(prop)) { if (!angular.equals(s[prop], t[prop])) { console.log("property " + prop + " does not match"); } } else { console.log("second object does not have property " + prop); } } }