var obj = {
posts: [
{
"text":"text",
"date":null,
"like":0,
"comments":[
{"comment":"Yorum 1", "like":100},
{"comment":"Yorum 2", "like":200},
{"comment":"Yorum 3", "like":300}
]
},
{
"text":"text2",
"date":null,
"like":0,
"comments":[
{"comment":"Yorum 4", "like":500},
{"comment":"Yorum 5", "like":600}
]
}
]
};
return obj;
PostCommand
$scope.posts = PostFactory.posts;
$scope.PostCommand = function(){
$scope.posts.comments.push({
"comment":$scope.comment,
"like":0
});
};
如何添加評論?如果用戶選擇哪一個添加到它 我使用路由器也許$ stateParams幫助我?
這在很大程度上取決於你如何顯示這些數據上。問題與現在相比過於寬泛。顯示更多與查看和路由相關的代碼 – charlietfl
https://plnkr.co/edit/pMo4g9jBAn2YDnh04JHv – ooz
如果沒有真實模板,演示並不是很有幫助 – charlietfl