'=' (expression) scope attributes use !== instead of angular.equals to compare

3,374 views
Skip to first unread message

Martin Probst

unread,
Jun 25, 2012, 11:37:03 AM6/25/12
to angular
Hi,

the new scope bindings in Angular 1.0 use !== to compare for equality, instead of angular.equals.

This means if you have any binding that constructs new objects as part of its computation, you'll run into the max $digest TTL issue.

Is this by design? The code we had before was working fine with accessor bindings (and it still looks to work fine, it's just one empty array that keeps the $digest spinning).

Martin

ste...@sock.org.uk

unread,
Jun 25, 2012, 12:16:19 PM6/25/12
to ang...@googlegroups.com
Hi Martin

If I've understood your question correctly, you just need to pass 'true' as the third parameter (objectEquality) in your calls to $watch [1] - this will ensure that calls to $digest use angular.equals [2].

I'm afraid I can't answer as to whether this is by design - I just know that it confused me a bit last week!

Martin Probst

unread,
Jun 25, 2012, 12:49:06 PM6/25/12
to ang...@googlegroups.com
If I've understood your question correctly, you just need to pass 'true' as the third parameter (objectEquality) in your calls to $watch [1] - this will ensure that calls to $digest use angular.equals [2].

I know, but this is actually set up by Angular itself, when setting up bindings for directives with scope: { foo: '=' }. So I have no chance of fixing this.

Martin

ste...@sock.org.uk

unread,
Jun 25, 2012, 1:44:08 PM6/25/12
to ang...@googlegroups.com
If I've understood your question correctly, you just need to pass 'true' as the third parameter (objectEquality) in your calls to $watch [1] - this will ensure that calls to $digest use angular.equals [2].

I know, but this is actually set up by Angular itself, when setting up bindings for directives with scope: { foo: '=' }. So I have no chance of fixing this.

In that case all I can do is agree with you that the new behaviour feels like a regression (but I'm quite new to angular so I'll expect to be proved wrong).

Stephen
Reply all
Reply to author
Forward
0 new messages