Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ng-if inside ng-bind Angular Js

<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.

like image 344
Atul Sharma Avatar asked Feb 06 '23 23:02

Atul Sharma


1 Answers

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

<span ng-repeat="tag in tags">
   {{tag + ($last ? "" : ",")}}
</span>
like image 75
Chrillewoodz Avatar answered Feb 08 '23 15:02

Chrillewoodz