ng-repeat: track by not implemented
The current implementation is broken. Track by expressions are actually parsed and processed in
https://github.com/angular/angular.dart/blob/master/lib/directive/ng_repeat.dart#L107
but the resulting _generateId is never used.
Please either:
- remove the dead code and update the documentation; or
- fix the implementation to support it.
We (AWV) would really like 2. because we use immutable objects a lot and track by is the only way to prevent ng-repeat from recreating elements all the time (and losing focus).
If you have immutable objects, than trackBy has no effect. trackBy is useful only when the object identity changes, but you want to pretend that it is the same object, to save yourself from removing and reinserting the ng-repeat row. In essence the trackBy is a custom equals method.
Could you better explain why you think trackBy would help you use case?
NOTE: trackBy is very hard to implement using the current architecture, and as such it is unlikely to get into the v1.x branch.
It helps for the case of having a List<ImmutableObject> and ImmutableObject changes. It doesn't help with deeper nesting (which we have, too), but it would be helpful already.
For me, the most important thing is to please update the documentation and remove the dead code if it is not going to land in Angular 1 at all because we spent time on it and I bet others try to use track by as well and get frustrated that it doesn't work even though the docs say it should and there is dead code for it in there.
So if you don't see this landing, update our user's expectations :)
Thanks, Andreas
On Wed, Feb 18, 2015 at 12:22 AM, Miško Hevery [email protected] wrote:
If you have immutable objects, than trackBy has no effect. trackBy is useful only when the object identity changes, but you want to pretend that it is the same object, to save yourself from removing and reinserting the ng-repeat row. In essence the trackBy is a custom equals method.
Could you better explain why you think trackBy would help you use case?
NOTE: trackBy is very hard to implement using the current architecture, and as such it is unlikely to get into the v1.x branch.
— Reply to this email directly or view it on GitHub https://github.com/angular/angular.dart/issues/1671#issuecomment-74777455 .
Why is this e-mail so short? Answer: five.sentenc.es.
+1 I spent some time helping someone until I realized that track by is not implemented. in fact we should throw on track by expressions with an useful message. I will make a PR unless someone beats me to it