khan4019/tree-grid-directive

Problem with ng repeat

Closed this issue · 2 comments

Hello together,

I m new to JS and angular and I m using your tree in a frontend where I fill the tree using a rest call.
If I clicked back in my browser and start to fill the tree again I get

Error: ngRepeat:dupes
Duplicate Key in Repeater

do you have any idee how to solve this? Did anyone face the same issue?
Thanks and regards.
Reem.

Hi Reem,
The Duplicate Key error happens when you have duplicate entries with same "DemographicId" in outermost level. It is probably happening because at every reload you are triggering the API and filling the already populated tree. You can check before calling the API, if tree is empty or you can exclusively empty the tree before filling it.
Interestingly, you don't get this error, if you have duplicate children.

Hi Shahrukh,

thanks for the answer. The problem is solved. I had to clear the children nodes before reinserting again.