【发布时间】:2016-04-26 05:46:51
【问题描述】:
我有一个如下的json。
{
"id":14,
"discussion":8,
"parent":0,
"userid":2,
"subject":"communication skill discussion 2",
"message":"<p>hi all to communication discussion 2 </p>",
"children":[
24,
16,
15
]
},
{
"id":15,
"discussion":8,
"parent":14,
"userid":2,
"subject":"Re: communication skill discussion 2",
"message":"<p>hiiiiiiiiii</p>",
"children":[
25,
23
],
},
{
"id":23,
"discussion":8,
"parent":15,
"userid":2,
"created":1461562317,
"modified":1461562317,
"mailed":0,
"subject":"Re: communication skill discussion 2",
"message":"<p>helloooo</p>",
"children":[
],
}
我想首先获取其 ID 与子数组中的元素匹配的详细信息 例如对于 id:14 有 3 个孩子 24,16,15。然后控件应该直接转到 id:15 并获取 id:15 的详细信息。再次 id 有孩子,例如。考虑 id:23 没有子节点,将直接打印消息。
请指导我如何使用 ng-repeat of angular 来实现这一点?
【问题讨论】:
-
是否要基于子级迭代子级
-
我认为需要更清晰,无法理解您的意思。尝试重新措辞。
-
是的,我想在 JSON 中浏览我收到的内容
-
我实际上是在设计论坛。我有一个父帖子,子帖子意味着回复父帖子等等。但是我收到的 json 显示的帖子顺序忽略了父子帖子之间的关系。所以在我的 json 中有一个子元素,它显示了对父帖子的回复数量并希望相应地显示。
-
Like post id: 23 是对 post id: 15 的回复,所以它应该只显示在它的父级下。就像我们在 stackoverflow 或任何其他此类论坛中一样。评论来自主要答案而不是结束。
标签: javascript angularjs json