Soubok Soubok - 1 year ago 79
AngularJS Question

Using comma as list separator with AngularJS

I need to create a comma-separated list of items:

<li ng-repeat="friend in friends">
<b ng-repeat="email in">{{email}}{{$last ? '' : ', '}}</b>...

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?


is there something simpler than:

<span ng-show="!$last">, </span>


You could do it this way:

<b ng-repeat="email in">{{email}}{{$last ? '' : ', '}}</b>

..But I like Philipp's answer :-)