1

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>

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

hmmm is a nice solution.. thnkx for help :D
@BrunoNovais - No problem! Make sure to mark my answer as correct if it worked for you. Thanks!
Yah.. only waiting for Stackoverflow allow me choice correct answer

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.