Reputation: 29
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>
Upvotes: 1
Views: 3067
Reputation: 7875
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
.
Upvotes: 1