用逗号与AngularJS列表分隔 [英] Using comma as list separator with AngularJS
本文介绍了用逗号与AngularJS列表分隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要创建一个逗号分隔的项目列表:
<李NG重复=朋友的朋友>
< b NG重复=电子邮件在friend.email> {{EMAIL}} {{$持续多久? '':','}}< / B> ...
< /李>
根据该AngularJS文档,没有控制流语句是允许在EX pressions。这就是为什么我的 {{$持续多久? '':','}}
不起作用
有用来创建逗号分隔的列表的替代方式?
修改1 结果
难道还有比更简单的东西:
<跨度NG秀=$即止!&GT中,< / SPAN>
解决方案
您可以做这种方式:
< b NG重复=电子邮件在friend.email> {{EMAIL}} {{$持续多久? '':','}}< / B>
..但我喜欢菲利普的回答: - )
I need to create a comma-separated list of items:
<li ng-repeat="friend in friends">
<b ng-repeat="email in friend.email">{{email}}{{$last ? '' : ', '}}</b>...
</li>
According to the AngularJS documentation, no control flow statements is allowed in expressions. This is why my {{$last ? '' : ', '}}
does not work.
Is there an alternative way to create comma-separated lists?
EDIT 1
is there something simpler than:
<span ng-show="!$last">, </span>
解决方案
You could do it this way:
<b ng-repeat="email in friend.email">{{email}}{{$last ? '' : ', '}}</b>
..But I like Philipp's answer :-)
这篇关于用逗号与AngularJS列表分隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文