Reputation: 937
I use ng-repeat in my code.
<span ng-repeat="provide in user.profiles">
<span ng-switch on="provide.provider">
<span ng-switch-when="google" class="color-google">GOOGLE</span>
<span ng-switch-when="yahoo" class="color-tinet">YAHOO</span>
</span>
<span> - </span>
</span>
How can I hide the last hyphen? Is there a way to hide the last item in ng-repeat?
Upvotes: 1
Views: 31
Reputation: 48968
Use the ng-hide
directive with the $last
special property:
<span ng-repeat="provide in user.profiles">
<span ng-switch on="provide.provider">
<span ng-switch-when="google" class="color-google">GOOGLE</span>
<span ng-switch-when="yahoo" class="color-tinet">YAHOO</span>
</span>
<span ng-hide="$last"> - </span>
</span>
For more information, see
Upvotes: 1
Reputation: 937
$last shows the last item in ng-repeat.
<span ng-repeat="provide in user.profiles">
<span ng-switch on="provide.provider">
<span ng-switch-when="google" class="color-google">GOOGLE</span>
<span ng-switch-when="yahoo" class="color-tinet">YAHOO</span>
</span>
<span ng-if="!$last"> - </span>
</span>
Upvotes: 1