所以我相當新的角度和我想要做的是採取從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