angularjs: fixed ng-repeat duplicate entry errors #726

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
4 participants
Contributor

callmehiphop commented Nov 19, 2013

Angular 1.2 breaks the application when rendering out duplicate entries pull from localStorage, a quick solution is tell the ng-repeat directive to track by $index.

Owner

addyosmani commented Nov 19, 2013

@passy as the member of the team with most Angular experience, could you walk through the issues introduced by 1.2 and the PRs kindly suggested by @callmehiphop so we can get our app in-line with that release? I'd do it myself but don't know enough about the 1.2 changes to competently land these.

Member

passy commented Nov 19, 2013

@addyosmani We recently reverted my change that added exactly this because it broke the navigation. I don't have much time today, but I want to get this right this time.

@addyosmani addyosmani referenced this pull request Nov 19, 2013

Closed

Upgrade other AngularJS implementation to 1.2 #718

4 of 4 tasks complete
Contributor

torifat commented Nov 19, 2013

@passy I checked it again later. I think we should better use track by $id(item) or we can introduce a id field in our data structure too. Then, we can use track by item.id

Also, they have suggested in their official documentation to use track by after the filter. It also does make sense if you think.

@callmehiphop Can you please do a little test for me. Add some tasks and mark some of them complete. Then refresh your browser a few times. And, try to use any of the filters. Does it work?

Member

passy commented Nov 19, 2013

I actually think that track by $index is fine in our case. The syntax in the PR is just wrong, the track by expression must come after the filter, otherwise the filter is ignored.

Contributor

callmehiphop commented Nov 19, 2013

@torifat Nope, doesn't work - probably because of what @passy just mentioned

@passy passy closed this in 443a527 Nov 19, 2013

Member

passy commented Nov 19, 2013

Thanks guys, I read through the long discussion on the Angular repo (starting here) and this seems to be the idiomatic way to solve this.

Contributor

torifat commented Nov 19, 2013

yeah, my bad. $index and item.id are almost same thing here.

Member

passy commented Nov 19, 2013

@torifat We don't expose an id on the objects, though.

@callmehiphop callmehiphop deleted the callmehiphop:ngrepeat_fix branch Nov 19, 2013

gustaff-weldon pushed a commit to gustaff-weldon/todomvc that referenced this pull request Dec 23, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment