如何根据表格大小定位下拉列表或下拉列表



我在一个表中有下拉列表,如果该行下方的表中没有空间,我需要将其更改为下拉列表。我怎样才能做到这一点?有人能帮忙吗示例代码http://jsfiddle.net/mhu23/YZx7R/22/

<div ng-controller="MyCtrl">
<div class="container">
<div class="row">
<div class="span2">
<table class="table">
<tr ng-repeat="row in [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]">
<td> <a>{{row}}</a>
</td>
<td>
<ul class="nav">
<!-- To create dropups instead of dropdowns i could add the class "dropup" to the li-element below. -->
<!-- But what I need is an inteligent mechanism that decides when to use dropdown and when to use dropup -->
<li class="dropdown pull-right"> <a class="btn-link dropdown-toggle">
<i class="icon-align-justify"></i>
</a>
<ul class="dropdown-menu">
<li ng-repeat="menu in [1,2,3]"> <a class="btn-link">{{menu}}</a>
</li>
</ul>
</li>
</ul>
</td>
</tr>
</table>
</div>
</div>
</div>

使用$last属性

类似于:

<li class="dropdown pull-right"
ng-class="{'dropup':$last}"> 

固定填充


如果你需要最后2个,你可以写:

ng-class="{'dropup': $index >= items.length-2}"

其中items=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]

Fiddle 2

最新更新