Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

add a way to turn on objectEquality for internal watches from a directive or expression. #3790

Closed
funkjunky opened this issue Aug 29, 2013 · 2 comments

Comments

@funkjunky
Copy link

I have to clone all my array every time I add or remove an element, because I have a textarea that has it's ng-model set to that array and it compares the arrays by reference.

There doesn't appear any way for me to tell the ng-model to use objectEquality, short of rewriting the ng-model directive.

(anyone wondering why I have an array set for the ng-model, it's because I convert from array to text and back to array again using a custom directive [and no, ng-list is not powerful enough for my use case (unless ngList can use regex to compress a list into a tally of items)])

@IgorMinar
Copy link
Contributor

We are not considering exposing objectEquality via directive api because deep watching is an easy performance trap.

In your case, you don't actually want to deep watch, but use watchCollection instead, which ngModel doesn't support right now.

this in fact affects ngList as well, which doesn't see updates done to the array without array identity changes: http://plnkr.co/edit/HDpJNYd1LVUxqnVhnz7X?p=preview

@IgorMinar
Copy link
Contributor

I'm closing this in favor of #8326

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants