【发布时间】:2013-11-21 12:53:59
【问题描述】:
有人可以告诉我我在这里做错了什么吗?
我正在检索一些数据并作为“productInfo”注入到控制器中。
我可以很好地加载数据,但是当我想在 ng-repeat 中定位特定值时,我没有得到想要的结果。我得到的最好的是 JSON 中的最后一组数据。
我正在从服务器获取 JSON,并且可以根据需要更改格式。我刚开始使用 Angular,如果有一个简单的答案,我们深表歉意。
HTML:
<div ng-controller="ProductStandardCtrl">
<p>Item:</p>
<article ng-repeat="item in items">
<img ng-src="{{item.img}}" class="logo" alt="">
<h4>{{item.title}}</h4>
</article>
</div>
JSON:
{
"description":"Lorem Ipsum",
"headline":"Promotion headline",
"items":{
"Standard":
{"img":"http://placehold.it/303x152",
"title":"Standard Product 1"
},
"Standard":
{"img":"http://placehold.it/303x152",
"title":"Standard Product 2"
},
"Standard":
{"img":"http://placehold.it/303x152",
"title":"Standard Product 3"
}
}
}
谢谢
【问题讨论】:
标签: javascript json angularjs angularjs-ng-repeat