fer / ion-tree-list

Ionic directive for displaying nested list items.

Home Page:http://fer.github.io/ion-tree-list/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error "duplicates are not allowed in ng-repeat" when switching ti ion-tab with ion-tree-list for the second time

patrickpirzer opened this issue · comments

Hi,

We have implemented the ion-tree-list in an Ionic-tabs-app and filled it with an array named componentTree.

<ion-tree-list id="validatetree" items="componentTree" collapsed="true"></ion-tree-list>

When we open in our main-tab by click the template/tab with the ion-tree-list for the first time it's okay.
But when we switch back to the main-tab and open the template/tab with the ion-tree-list for the second time, we get the following error message:

ionic.bundle.js:26794 Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: item in items, Duplicate key: object:68, Duplicate value: {"id":1,"name":"Komponente 1","parentid":0,"isEnabled":true,"tree":[],"Eigenschaften":[{"Seriennummer":"1234","Groesse":20,"Laenge":500,"collapsed":true,"depth":2}],"collapsed":true,"depth":1}
http://errors.angularjs.org/1.5.3/ngRepeat/dupes?p0=item%20in%20items&p1=ob…true%2C%22depth%22%3A2%7D%5D%2C%22collapsed%22%3Atrue%2C%22depth%22%3A1%7D
at ionic.bundle.js:13438
at ngRepeatAction (ionic.bundle.js:42169)
at $watchCollectionAction (ionic.bundle.js:30102)
at Scope.$digest (ionic.bundle.js:30239)
at Scope.$apply (ionic.bundle.js:30503)
at HTMLBodyElement. (ionic.bundle.js:26543)
at defaultHandlerWrapper (ionic.bundle.js:16787)
at HTMLBodyElement.eventHandler (ionic.bundle.js:16775)
at triggerMouseEvent (ionic.bundle.js:2953)
at tapClick (ionic.bundle.js:2942)

The array is created absolutely new each time the template/tab is loaded and i saw in the debugger that there are no duplicates.

Can it be that You need ng-repeat="item in item.tree track by $index"?

From ion-tree-list.tmpl.html:

Or have i to clear the source of the tree?

Thanks in advance!

Sorry, it was our fault.
A colleague of mine has forgotten to clear the array before refilling it.
But maybe my hint with track would be something for later Versions of the ion-tree-list.
Bye!

commented

@patrickpirzer thank you for collaborating. Feel free to PR your hint!