我是很新的角度,我已經成功地到達這裏:如何使用角度呈現特定數據?
<tr ng-repeat="spec in res">
<td> {{$index + 1}} </td>
<td>{{ spec }}</td>
</tr>
目前,我的輸出是:
[["suite1",{"id":"suite1","description":"test cases","fullName":"my cases","failedExpectations":[],"status":"finished","specs":[{"id":"spec0","description":"should be able to add an unit","fullName":"etc cases","failedExpectations":[],"passedExpectations":[],"pendingReason":"","status":"passed"}]},"timestamp: Thu Apr 20 2017 09:47:38 GMT+0300 (EEST)"]]
如何顯示某個特定領域? 。?(例如ID或描述或全名
編輯:這裏
JSON結果
<pre>{{ res | json }}</pre>
結果:我使用的角度1.6.3
EDIT2。
[
"[[\"suite1\",{\"id\":\"suite1\",\"description\":\"test cases\",\"fullName\":\"my cases\",\"failedExpectations\":[],\"status\":\"finished\",\"specs\":[{\"id\":\"spec0\",\"description\":\"should be able to create a room\",\"fullName\":\"should be able to add an unit\",\"failedExpectations\":[],\"passedExpectations\":[],\"pendingReason\":\"\",\"status\":\"passed\"}]},\"timestamp: Thu Apr 20 2017 09:47:38 GMT+0300 (EEST)\"]]"
]
我還創建了一個將數組轉換爲對象的小函數:
function toObject(arr) {
let rv = {};
for (let i = 0; i < arr.length; ++i)
if (arr[i] !== undefined) rv[i] = arr[i];
return rv;
}
console.log(toObject(events));
$scope.res = toObject(events);
或
$scope.res = toObject(events);
沒有什麼區別
這,翻譯資料,到這一點:
Object {0: "[["suite1",{"id":"suite1","description":"RW - rate…tamp: Fri Apr 21 2017 11:45:06 GMT+0300 (EEST)"]]", 1: "[["suite1",{"id":"suite1","description":"rates","f…tamp: Fri Apr 21 2017 11:45:55 GMT+0300 (EEST)"]]", 2: "[["suite1",{"id":"suite1","description":"rates","f…tamp: Fri Apr 21 2017 11:46:12 GMT+0300 (EEST)"]]"}
沒有任何東西被渲染,除了索引計數器。 –
結帳上傳的圖片 –
我有一個額外的「在$ scope.res,請參閱編輯的json輸出 –