Search code examples
angularjsonsen-ui

OnsenUI List and ng-repeat issue


I wrote a simple ng-repeat example using Onsen-UI, it works great (see my codepen) but it doesn't work when I add more variable in var city

Update #1

JS

    var city=[...'Kumbakonam','Kumily']; //Works

but if i add more variables, like

var city=[...'Kumbakonam','Kumily','city','city','city','city','city','city','city','city','city','city','city']; //Not Works

Codepen that works

Codepen that doesn't

Am i missing something or is it a limitation or something like that. Please explain.

Thank you guys.


Solution

  • You should use the console while developing. It shows what's wrong:

    Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: list in cityList, Duplicate key: string:City, Duplicate value: "City"
    

    You aren't allowed to repeat values in the ngRepeat directive.