Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up
<span ng-repeat="tag in tags">
   {{tag + "," }}
</span>

I need to remove , after the last element. I know ng-if="$last" can solve the problem. But, as I don't have any parent element for {{tag}} I can't use ng-if so, just need some work around.

share|improve this question
1  
check this answer – abpatil 50 mins ago
    
@abpatil charm !! You saved my day :) – atulquest93 48 mins ago
up vote 1 down vote accepted

You should use a ternary together with () in order to prevent weird outcome:

<span ng-repeat="tag in tags">
   {{tag + ($last ? "" : ",")}}
</span>
share|improve this answer

Use a ternary operator within the mustache like this:

<span ng-repeat="tag in tags">
   {{tag + $last ? "" : "," }}
</span>

Cheers!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.