I built an Angular app and I am using ng-repeat
to show data from the model in to an html view. But i am getting wrong values:
Model looks like this:
[{
id : 1,
name : 'jijo'
address : 'addressone',
},
{
id : 2,
name : 'albert'
address : 'addressone',
},
{
id : 3,
name : 'moana'
address : 'addressone',
},
{
id : 4,
name : 'card'
address : 'addressone',
}
]
Html code looks like this:
<section id="main" ng-repeat="(id, name) in data.repo track by id"
<div id="sub_main_one">
{{id}} //prints one
</div>
<div id="sub_main_two">
{{id}} //prints one
</div>
<div id="sub_main_three">
{{id}} //prints one
</div>
<div id="sub_main_four">
{{id}} //prints one
</div>
<div id="sub_main_five">
{{id}} //suppose to be one but prints 4 on the first repeat
</div>
</section>
The id is printing 1 in most of the divs, but in the last div it's giving me a wrong value (4), which is the id from the last object in the array. How can I fix this issue ?..