Rober
Rober

Reputation: 6108

Angularjs ng-repeat with comma separated but last element

I have a list of elements (tags) that I want to show comma separated but last one. But it´s not working. Commas are not displayed.

<span ng-repeat="tag in post.tags"><a href="">{{tag.name | translate}}</a><span ng-show="{{!$last}}">, </span></span>

Upvotes: 1

Views: 997

Answers (3)

Kirill Husiatyn
Kirill Husiatyn

Reputation: 828

I tried to do the similar example and looks like the problem is with a filter 'translate'

{{tag.name | translate}}

http://jsfiddle.net/kikill/re4x99ra/

Upvotes: 1

Martin Seeler
Martin Seeler

Reputation: 6982

Try ng-hide="$last" instead. You don't need {{ and }} in this context.

Upvotes: 1

Rober
Rober

Reputation: 6108

All right,

I finally solved it with: {{{true: '', false: ', '}[$last]}}

Upvotes: 0

Related Questions