我在代码中使用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> - </span>
</span>
如何隐藏最后一个连字符? 有没有办法隐藏ng-repeat中的最后一个项目?
答案 0 :(得分:1)
$ last显示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>
答案 1 :(得分:1)
将ng-hide
指令与$last
特殊属性一起使用:
<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>
有关更多信息,请参见