Javascript AngularJS ng使用#键重复数据

Javascript AngularJS ng使用#键重复数据,javascript,json,angularjs,Javascript,Json,Angularjs,我尝试迭代的数据如下所示: { "request": "Stream/GetDigest", "response": { "success": true, "content": { "0": { "artifact_id": "36", "ti

我尝试迭代的数据如下所示:

    {
            "request": "Stream/GetDigest",
            "response": {
                "success": true,
                "content": {
                    "0": {
                        "artifact_id": "36",
                        "timestamp": "2013-08-20 11:59:00",
                        "modified": "2013-08-20 11:59:00",
                        "text": "Why did the last one BLAHHHHH duplicate? I don't think I clicked it twice...",
                        "author_desc": "",
                        "object_type": "artifact",
                        "comments": []
                    },
                    "1": {
                        "artifact_id": "35",
                        "timestamp": "2013-08-20 11:57:51",
                        "modified": "2013-08-20 11:57:51",
                        "text": "This is a new artifact for a new day.",
                        "author_desc": "",
                        "object_type": "artifact",
                        "comments": []
                    },
                    "2": {
                        "artifact_id": "34",
                        "timestamp": "2013-08-20 11:57:50",
                        "modified": "2013-08-20 11:57:50",
                        "text": "This is a new artifact for a new day.",
                        "author_desc": "",
                        "object_type": "artifact",
                        "comments": []
                    },
                    "3": {
                        "artifact_id": "30",
                        "timestamp": "2013-08-19 13:15:32",
                        "modified": "2013-08-20 11:01:12",
                        "text": "This is some awesome text that we want to display!",
                        "author_desc": "",
                        "object_type": "artifact",
                        "comments": {
                            "5": {
                                "artifact_id": "30",
                                "comment_id": "5",
                                "user_id": "5",
                                "author_desc": "Michael C.",
                                "timestamp": "2013-08-19 16:18:12",
                                "private": "1",
                                "reported": 0,
                                "moderated": 0,
                                "banned": 0,
                                "text": "This is a createComment artifact"
                            },
                            "6": {
                                "artifact_id": "30",
                                "comment_id": "6",
                                "user_id": "5",
                                "author_desc": "Michael C.",
                                "timestamp": "2013-08-20 11:01:12",
                                "private": "1",
                                "reported": 0,
                                "moderated": 0,
                                "banned": 0,
                                "text": "This is another comment"
                            }
                        }
                    },
                    "4": {
                        "artifact_id": "33",
                        "timestamp": "2013-08-19 15:25:11",
                        "modified": "2013-08-19 15:25:11",
                        "text": "Kitten Ipsum dolor sit amet urna, bibendum life litora quis wish vel happy litora kitties laoreet buddy Praesent her. Lure, local ipsum amet urna molestie Nam. Snuggliest sed first chuf his cat kitten, ac climb the curtains cat eget sagittis et front",
                        "author_desc": "",
                        "object_type": "artifact",
                        "comments": []
                    }
                }
            }
        }
<li ng-repeat="thing in GetDigestList.response.content">
目标是迭代response.content.#部分。目前,我正在通过一个GetDigest变量通过控制器(baby steps-我是新的)传递内容。因此,我的NGR中继器如下所示:

    {
            "request": "Stream/GetDigest",
            "response": {
                "success": true,
                "content": {
                    "0": {
                        "artifact_id": "36",
                        "timestamp": "2013-08-20 11:59:00",
                        "modified": "2013-08-20 11:59:00",
                        "text": "Why did the last one BLAHHHHH duplicate? I don't think I clicked it twice...",
                        "author_desc": "",
                        "object_type": "artifact",
                        "comments": []
                    },
                    "1": {
                        "artifact_id": "35",
                        "timestamp": "2013-08-20 11:57:51",
                        "modified": "2013-08-20 11:57:51",
                        "text": "This is a new artifact for a new day.",
                        "author_desc": "",
                        "object_type": "artifact",
                        "comments": []
                    },
                    "2": {
                        "artifact_id": "34",
                        "timestamp": "2013-08-20 11:57:50",
                        "modified": "2013-08-20 11:57:50",
                        "text": "This is a new artifact for a new day.",
                        "author_desc": "",
                        "object_type": "artifact",
                        "comments": []
                    },
                    "3": {
                        "artifact_id": "30",
                        "timestamp": "2013-08-19 13:15:32",
                        "modified": "2013-08-20 11:01:12",
                        "text": "This is some awesome text that we want to display!",
                        "author_desc": "",
                        "object_type": "artifact",
                        "comments": {
                            "5": {
                                "artifact_id": "30",
                                "comment_id": "5",
                                "user_id": "5",
                                "author_desc": "Michael C.",
                                "timestamp": "2013-08-19 16:18:12",
                                "private": "1",
                                "reported": 0,
                                "moderated": 0,
                                "banned": 0,
                                "text": "This is a createComment artifact"
                            },
                            "6": {
                                "artifact_id": "30",
                                "comment_id": "6",
                                "user_id": "5",
                                "author_desc": "Michael C.",
                                "timestamp": "2013-08-20 11:01:12",
                                "private": "1",
                                "reported": 0,
                                "moderated": 0,
                                "banned": 0,
                                "text": "This is another comment"
                            }
                        }
                    },
                    "4": {
                        "artifact_id": "33",
                        "timestamp": "2013-08-19 15:25:11",
                        "modified": "2013-08-19 15:25:11",
                        "text": "Kitten Ipsum dolor sit amet urna, bibendum life litora quis wish vel happy litora kitties laoreet buddy Praesent her. Lure, local ipsum amet urna molestie Nam. Snuggliest sed first chuf his cat kitten, ac climb the curtains cat eget sagittis et front",
                        "author_desc": "",
                        "object_type": "artifact",
                        "comments": []
                    }
                }
            }
        }
<li ng-repeat="thing in GetDigestList.response.content">
  • 我如何使它遍历这个json的子部分

    谢谢

    像这样的

    <li ng-repeat="(index, content) in GetDigestList.response.content">
       <!-- ... -->
    </li>
    

  • 如果您设法将内容作为数组,则可以使用each指令生成的$index。
    但为了以防万一,请检查$index是否不返回字符串键。

    如果内容是数组就更好了。不幸的是,我无法控制数据源。就是这样!非常感谢。NPA+1也很好:)@flashpunk:还要注意,
    ng repeat
    希望它的键是唯一的。必须使用
    track by
    指定索引变量。尽管如此,Angular的
    ng repeat
    文档中提供了大量信息和这个问题的答案。值得一看;)