Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have a little Issue.. My items have attributes and each attribute is used like key and value.

I need put value from attribute key desctiption in my page.. but i dont know how do it.

Here is my json data

[
{
    "id": 2323,
    "name": "small ring",
    "attributes": [
        {
            "key": "weight",
            "value": "90"
        },
        {
            "key": "description",
            "value": "A little ring"
        }
    ]
},
{
    "id": 2324,
    "name": "big ring",
    "attributes": [
        {
            "key": "weight",
            "value": "90"
        },
        {
            "key": "description",
            "value": "A Big ring"
        }
    ]
}]

Here is my html body.

<div class="list-group ">
    <a href="#" ng-repeat="item in items " class="list-group-item clearfix">
    <span  style="padding-left:5px;padding-right:5px;" class="pull-left">
        {{item.name}}
        <p><small>{{item.attribute}} </small></p><!-- Here -->
    </span>
    </a>
</div>
share|improve this question
up vote 1 down vote accepted

A quick solution:

<div class="list-group ">
    <a href="#" ng-repeat="item in items " class="list-group-item clearfix">
    <span  style="padding-left:5px;padding-right:5px;" class="pull-left">
        {{item.name}}
        <p><small>
            <span ng-repeat="attr in item.attributes" ng-if="attr.key == 'description'">{{ attr.value }}</span>
        </small></p>
    </span>
    </a>
</div>

This should work. It loops through the attributes but should only display the attribute if its key is equal to description.

share|improve this answer
    
hmmm is a nice solution.. thnkx for help :D – Bruno Novais Jan 20 '15 at 10:54
    
@BrunoNovais - No problem! Make sure to mark my answer as correct if it worked for you. Thanks! – DesignerGuy Jan 20 '15 at 10:56
1  
Yah.. only waiting for Stackoverflow allow me choice correct answer – Bruno Novais Jan 20 '15 at 10:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.