我正在Angular中创建一个WP主题,我对如何显示注释感到困惑。我可以很容易地在列表中显示注释,但它不会将回复放在正确的位置。
到目前为止,我已经创建了一个从API获取注释的指令,但我不知道构建注释线程的有效方法。
对此有何想法?
以下是wordpress API数据的示例:
[
{
id:4,
post:350,
parent:0,
author:1,
author_name:"Callum",
author_url:"",
date:"2016-06-23T15:04:48",
date_gmt:"2016-06-23T15:04:48",
content:{
rendered:"<p>Nice</p> "
},
link:"http://localhost:8888/callum/dummy-post/comment-page-1/#comment-4",
status:"approved",
type:"comment",
author_avatar_urls:{
24:"http://0.gravatar.com/avatar/328026ec83c49132546a48d7326d3936?s=24&d=mm&r=g",
48:"http://0.gravatar.com/avatar/328026ec83c49132546a48d7326d3936?s=48&d=mm&r=g",
96:"http://0.gravatar.com/avatar/328026ec83c49132546a48d7326d3936?s=96&d=mm&r=g"
},
_links:{
self:[
{
href:"http://localhost:8888/callum/wp-json/wp/v2/comments/4"
}
],
collection:[
{
href:"http://localhost:8888/callum/wp-json/wp/v2/comments"
}
],
author:[
{
embeddable:true,
href:"http://localhost:8888/callum/wp-json/wp/v2/users/1"
}
],
up:[
{
embeddable:true,
post_type:"post",
href:"http://localhost:8888/callum/wp-json/wp/v2/posts/350"
}
]
}
},
{
id:5,
post:350,
parent:0,
author:1,
author_name:"Callum",
author_url:"",
date:"2016-06-23T15:05:28",
date_gmt:"2016-06-23T15:05:28",
content:{
rendered:"<p>Another</p> "
},
link:"http://localhost:8888/callum/dummy-post/comment-page-1/#comment-5",
status:"approved",
type:"comment",
author_avatar_urls:{
24:"http://0.gravatar.com/avatar/328026ec83c49132546a48d7326d3936?s=24&d=mm&r=g",
48:"http://0.gravatar.com/avatar/328026ec83c49132546a48d7326d3936?s=48&d=mm&r=g",
96:"http://0.gravatar.com/avatar/328026ec83c49132546a48d7326d3936?s=96&d=mm&r=g"
},
_links:{
self:[
{
href:"http://localhost:8888/callum/wp-json/wp/v2/comments/5"
}
],
collection:[
{
href:"http://localhost:8888/callum/wp-json/wp/v2/comments"
}
],
author:[
{
embeddable:true,
href:"http://localhost:8888/callum/wp-json/wp/v2/users/1"
}
],
up:[
{
embeddable:true,
post_type:"post",
href:"http://localhost:8888/callum/wp-json/wp/v2/posts/350"
}
]
}
},
{
id:6,
post:350,
parent:4,
author:1,
author_name:"Callum",
author_url:"",
date:"2016-06-23T15:05:35",
date_gmt:"2016-06-23T15:05:35",
content:{
rendered:"<p>Reply to nice</p> "
},
link:"http://localhost:8888/callum/dummy-post/comment-page-1/#comment-6",
status:"approved",
type:"comment",
author_avatar_urls:{
24:"http://0.gravatar.com/avatar/328026ec83c49132546a48d7326d3936?s=24&d=mm&r=g",
48:"http://0.gravatar.com/avatar/328026ec83c49132546a48d7326d3936?s=48&d=mm&r=g",
96:"http://0.gravatar.com/avatar/328026ec83c49132546a48d7326d3936?s=96&d=mm&r=g"
},
_links:{
self:[
{
href:"http://localhost:8888/callum/wp-json/wp/v2/comments/6"
}
],
collection:[
{
href:"http://localhost:8888/callum/wp-json/wp/v2/comments"
}
],
author:[
{
embeddable:true,
href:"http://localhost:8888/callum/wp-json/wp/v2/users/1"
}
],
up:[
{
embeddable:true,
post_type:"post",
href:"http://localhost:8888/callum/wp-json/wp/v2/posts/350"
}
],
in-reply-to:[
{
embeddable:true,
href:"http://localhost:8888/callum/wp-json/wp/v2/comments/4"
}
]
}
}
]