【发布时间】:2015-07-03 20:46:49
【问题描述】:
我正在使用 Angular 从 Web 服务中获取数据,数据是 JSON 格式:
{
"items": [{
"id": 2,
"catId": 1,
"content": "ddddddddddddddddd",
"type": 0,
"comments": [{
"id": 0,
"postId": 0,
"userId": 0,
"content": "nincompoop",
"ptime": "2015"
}, {
"id": 0,
"postId": 0,
"userId": 0,
"content": "lol",
"ptime": "2015"
}],
"Likes": []
}, {
"id": -1,
"catId": 1,
"content": "first post",
"type": 0,
"comments": [{
"id": 1,
"postId": 0,
"userId": 0,
"content": "first Comment",
"ptime": "2015"
}],
"Likes": [{
"id": 1,
"name": "Rawhi"
}]
}]
}
用户 ID 也存储在 javascript 参数中,如何遍历每个帖子的“item.likes”并确定用户 ID 是否存在?谢谢你
【问题讨论】:
-
使用
javascript或者你想在template中使用ng-Repeat