angularjs - Duplicate Key in Repeater, track by creates problems -


i have object trying ng-repeat through.

the object this:

ctrl.obj = {     "1": ["val1", "val2", ... ],     "3": ["val1", "val2", ... ],     ...     "20": ["val1", "val2", ... ] } 

when try:

<ul ng-repeat="item in ctrl.obj"></ul> 

i angular error:

error: ngrepeat:dupes duplicate key in repeater 

the standard solution use track $index. not work scenario though, because causes every integer between 0 , 20 appear, though have 1, 3, 7, 10, etc. ideally not reformat object, being loaded outside app ~ though seems recurring necessity angular.

what options repeating through object?

this object dictionary, each property key, , each array value. iterate through properly, need 2 separate ng-repeat. following:

<div ng-repeat="(key, value) in ctrl.obj">     {{key}} : {{value}}     <div ng-repeat="item in value">         {{item}}     </div> </div> 

there may else going on here, because unable reproduce error experiencing when using syntax, though state syntax causes error in situation. can post sample of data cause error?

http://plnkr.co/edit/lvvpxnqm6lugvel4wqt9?p=preview

this plunker using original <ul>, , not producing of errors describing. seems though haven't provided accurate representation of object trying display here.

http://plnkr.co/edit/xgded2ebrf0xkfuupoyr?p=preview

https://docs.angularjs.org/api/ng/directive/ngrepeat


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -