Reputation: 14283
I'm trying to display values from an array using ng-repeat, but i'm clearly missing something here and I cannot figure out what it is exactly.
Here's an example: http://codepen.io/nickimola/pen/dMNawj?editors=1010
json object:
$scope.data = [
{"id": 0, "settings": {"SP": 21,"Active": false,"Output": true,"Link": [2,3,4]}},
{"id": 1, "settings": {"SP": 1,"Active": true,"Output": true,"Link": [5]}},
{"id": 2, "settings": {"SP": 30,"Active": false,"Output": true,"Link": []}},
];
html:
<ion-content>
<ion-list class="list">
<div ng-repeat="b in data">
<ion-item class="item item-stable"
ng-click="toggleGroup(b)"
ng-class="{active: isGroupShown(b)}">
{{b.id}}
</ion-item>
<div ng-repeat="(key, value) in b.settings" ng-show="isGroupShown(b)">
<div ng-repeat="links in key" ng-if="key == 'Link'">
<ion-item class="item-accordion">
{{links}}
</ion-item>
</div>
</div>
</ion-list>
</ion-content>
I would like to display only the numbers inside Link
array, but at the moment all I can see is all the letters in the word "LINK", one for each accordion element.
Any help?
Thanks a lot
Upvotes: 0
Views: 230
Reputation: 42
> <div ng-repeat="(key, value) in b.settings" ng-show="isGroupShown(b)">
> <div ng-repeat="links in **value**" ng-if="key == 'Link'">
> <ion-item class="item-accordion">
> {{links}}
> </ion-item> </div>
Please replace "key" with "value" in your inner "ng-repeat". Thanks.
Upvotes: 0
Reputation: 300
Here it is:
<div ng-repeat="links in value" ng-if="key == 'Link'">
Upvotes: 4