0

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

2
  • 1
    try with "links in value" not "links in key" Commented Apr 6, 2016 at 14:51
  • it was so simple. Thanks a lot, it worked. If you want to explain and had this as an answer i can select it. Commented Apr 6, 2016 at 14:52

2 Answers 2

4

Here it is:

<div ng-repeat="links in value" ng-if="key == 'Link'">
Sign up to request clarification or add additional context in comments.

Comments

0
> <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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.