我试图添加一个仅显示特定索引号的按钮:
<tbody data-ng-repeat="(wholesalerIndex,wholesaler) in wholesalers">
<tr>
<td>
<button ng-if="$index != 0 || $index != 3" class="btn btn-danger" data-ng-click="removeWholesaler(wholesaler, wholesalerIndex)">Up</button>
<button class="btn btn-danger" data-ng-click="removeWholesaler(wholesaler, wholesalerIndex)">Down</button>
</td>
</tr>
</tbody>
ng-if isn不工作。当我有1个条件ng-if="$index != 0"
时它工作正常,但是当我尝试添加OR(||)语句时它停止工作。
我做错了什么,我该如何解决?
答案 0 :(得分:1)
My guess is the logic is off. Try logical and instead of logical or.
<button ng-if="$index != 0 && $index != 3" class="btn btn-danger" data-ng-click="removeWholesaler(wholesaler, wholesalerIndex)">Up</button>
答案 1 :(得分:0)
Just use ng-show it will work :)
<tbody data-ng-repeat="(wholesalerIndex,wholesaler) in wholesalers">
<tr>
<td>
<button ng-show="$index != 0 || $index != 3" class="btn btn-danger" data-ng-click="removeWholesaler(wholesaler, wholesalerIndex)">Up</button>
<button class="btn btn-danger" data-ng-click="removeWholesaler(wholesaler, wholesalerIndex)">Down</button>
</td>
</tr>
</tbody>
I hope that this helps.