Ng repeat sub array

Hi I tried to expand the tabs / friends example with some extra levels of detail in the friends array

I can get a list of the details as such but it shows the array:
{{friend.extras}}

My question is two fold.

How would i get the value of skills?

  • how would i repeat the items from extras in my main view in the friends detail page
    , so i can layout it nicely?
    Like fe. (this is dummy code / i can’t find the sollution)

     <p>{{friend.skills}} - {{friend.skills.value}}</p> // this needs to show  skills - 7
    

Snipper from my array:

Var friends [{Name: ‘tester’
,
extras:[
{
skills:7,
pens:0,
crayons:0,
papers:8
}
],

Etc
}]

Here is how to get the value of skills:

<ion-item ng-repeat="friend in friends">
    <p ng-repeat="extra in friend.extras">
        {{ extra.skills }}
    </p>
</ion-item>

I’m not sure what you mean by ‘layout it nicely’, can you provide an example of what you mean?

Thanks. However I guess my question was badly formulated.
What i mean is to have a label based on everything thats inside of this sub array and more specific, to run a loop through every item in extra’s to display it.
Fe:

Skills - 7
Papers - 0
Etc…

Fe:
{{extras.skills.label (for the label) }} - {{extras.skills (for the value)}}

As my object has the name and value. I can get the value as you mentioned but somehow i can’t get the label itself. Lets say I have hundreds of extra data fields i want to show.

I could write the label myself as

Skills - {{extras.skills}}

But it seems cumbersome especially if i have a big list of items right?

Later I want to be able to filter based on for example the skills based on the number.
So i am looking for a way to get all this data.
(as you might expect i am not really a coder and very new to ionic :))
My best regards
Peter

Okay my bad

I changed my sub array to

{
Label:“skills”,
Value:1
},
{
Label:“paper”,
Value:7
}, etc

This seems to get what i want.

Now up to the filtering part :wink:

1 Like