From 7e96af0fdd9af8c479992363f68578305df0337e Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 19 Jul 2010 12:29:24 -0700 Subject: added equals method to angular.equals and $equals --- example/temp.html | 23 +++++++++++++++-------- src/Angular.js | 28 +++++++++++++++++++++++++++- src/AngularPublic.js | 1 + src/apis.js | 3 ++- test/AngularSpec.js | 27 +++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 10 deletions(-) diff --git a/example/temp.html b/example/temp.html index d07a6948..838a463d 100644 --- a/example/temp.html +++ b/example/temp.html @@ -1,13 +1,20 @@ - - + + - + + - {{$location.hashSearch.order}}
- A
- B
- C
- {{$location.hashSearch.order}}
+ Hello {{'World'}}! diff --git a/src/Angular.js b/src/Angular.js index 07e9096b..e39e31c9 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -263,6 +263,32 @@ function copy(source, destination){ } } +function equals(o1, o2) { + if (o1 == o2) return true; + var t1 = typeof o1, t2 = typeof o2, length, key, keySet; + if (t1 == t2 && t1 == 'object') { + if (o1 instanceof Array) { + if ((length = o1.length) == o2.length) { + for(key=0; key