【发布时间】:2018-08-18 03:15:21
【问题描述】:
我是网络开发的新手。我确实有一个 json obj,就像
$scope.jsonData = {
"messages": {
"A": [{
"missingFields": [{
"RESPONSIBILITY": ""
}],
"temporaryId": 2,
"messages": "",
"id": 2,
"content": ""
}, {
"missingFields": [{
"RESPONSIBILITY": ""
}],
"temporaryId": 3,
"messages": "",
"id": 3,
"content": ""
}, {
"missingFields": [{
"RESPONSIBILITY": ""
}],
"temporaryId": 4,
"messages": "",
"id": 4,
"content": ""
}],
"B": [{
"missingFields": [{
"CITY": ""
}, {
"PINCODE": ""
}],
"messages": "No Address details found.",
"id": -1,
"content": ""
}]
}
}
现在我想遍历这个对象,我想得到"RESPONSIBILITY" 字段。我在这里尝试过-
for (var i=0; i < $scope.jsonData.messages.length; i++) {
}
但它给出的消息长度为undefined。所以,我也想在 angular code 中使用它。我用过 -
ng-repeat="suggestion in jsonData.messages
谁能给我解释一下。我搜索了很多并尝试过,所以我问了这个问题。
【问题讨论】:
-
messages是一个对象而不是一个数组 -
好的,谢谢您的信息
-
还有
$scope.jsonobj$scope.jsonData -
根据 cmets 更新代码
标签: javascript jquery angularjs html