所以我相当新的角度和我想要做的是采取从RESTful调用获得的JSON集合,并通过每个循环来显示它们的值,同时关联它在href中的指定ID。ng-repeat无法正确执行angularjs
下面你会发现什么,我曾尝试:
<div class="span2">
<!--Sidebar content-->
Search: <input ng-model="query">
Sort by:
<select ng-model="orderProp">
<option value="name">Alphabetical</option>
<!--option value="age">Newest</option>
<option value="-age">Oldest</option-->
</select>
</div>
<div class="span10">
<!--Body content-->
<ul class="documents">
<li ng-repeat="document in documents | orderBy:orderProp" class="thumbnail">
<a href="#/rest/{{document.document_id}}">{{document.title}}</a>
</li>
</ul>
<pre>{{ documents | json }}</pre>
</div>
的S-HTTP调用:
function DocListCtrl($scope, $http)
{
console.log('getting documents data');
$http.get('/*RESTful call here*/').success(function(data)
{
$scope.documents = data;
});
$scope.orderProp = 'name';
}
当我运行的页面让我的名单使用
<pre>{{ documents | json }}</pre>
没问题
但ng-repeat无法执行。
编辑
这里是我正在使用的Json的一个例子。
{
"next": {},
"items": [
{
"document_id": 3177554002,
"title": "title of some item"
}
]
}
究竟是我正在做错误的ng-repeat调用,没有按我希望的方式列出我的数据?
感谢您的帮助
你的JSON响应是什么样的? –
你看到了什么错误? – zsong
@MikeRobinson Json已添加 – James213