Hi Michael,
You are right, that version will not work, you can try this instead:
`function valReturn(x) {return function () {return x}}`
However you have to be careful with stuff like this, as it is very CPU
intensive. It is even way more costly then a deep watch. A deep watch can
stop traversing the array/object on first change detection. this version
will iterate the entire array every time. Also, if you push/pop an element,
it will fail. To solve that you will have to add yet another watch that
add/removes the watcher for the element pushed/popped. Even more CPU
intensive.
Those reasons and performance are the motivation behind the design. Every
$watch you add to the application needs to be evaluated on every data
change. When you support something like this out of the box, it tends to
get over-used. The current API is set up so, that it discourages this type
of usage.
Does that help you a bit more?
Regards
Sander
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.