简体   繁体   English

如何在阵列角度显示对象?

[英]How to show object in array angular?

How to show comments in items? 如何在项目中显示评论?

This is where items save 这是项目保存的地方

$scope.items = [
{ 'item': 'one',
'comments':[{'comment':'comment'}]
},
{ 'item': 'two',},
{'item': 'three'}
];


<ul>
<li ng-repeat="ite in items">
{{ite.item}} {{ite.comments.length}}
<button ng    click="remove($index)">Remove</button> <div ng-repeat="c in ite.comments">{{c.comment}}</div>
</li>

</ul>

http://plnkr.co/edit/19w1Q3XhoWQcpxm5SuxX?p=preview http://plnkr.co/edit/19w1Q3XhoWQcpxm5SuxX?p=preview

You Just missed to add your comment Div in between the list tag. 您只是错过了在列表标签​​之间添加注释Div的操作。 please update the code like above code. 请像上面的代码一样更新代码。 I have checked on Plunker. 我检查了Plunker。

<li ng-repeat="ite in items">
{{ite.item}} {{ite.comments.length}}
<button ng-click="remove($index)">Remove</button> <div ng-repeat="c in ite.comments">{{c.comment}}</div></li>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM