我有這樣一個JSON對象,所以:循環到JSON值添加到陣列
$scope.object = {
'thing1': {
'content': 'blah blah',
'order': '1',
},
'thing2': {
'content': 'blah blah blah',
'order': '2',
},
}
我想補充一點,與「內容」鍵的array.I相信這點對應的值:
var things=[];
for (x in $scope.object){
things.push(x.content);
}
它不起作用。它只是返回undefined。有任何想法嗎?
[請看看這個討論] [1] [1]:http://stackoverflow.com/questions/921789/how-to-loop-through-javascript-object-literal-with-objects-as-members – caoglish