table某列的按钮根据 状态来判断是否显示
table某列的按钮根据 状态来判断是否显示:
当status为 stop时候,stop按钮不显示。
jobsListView.html
<td>
<a class="btn btn-primary btn-xs" ng-click="vm.stopJob(job.id)">
<i></i> Stop
</a>
</td>
jobsListCtrl.js
jobResource.query(function(data) {
vm.jobs = data;
for (var i = 0; i < vm.jobs.length; i++) {
if(vm.jobs[i].Status === 'Running'){
//这里逻辑应该如何修改
}
}
})
或者哪有参考例子?
6 回复
找到类似方法
Use nested inline if-then statements (Ternary Operators)
<div ng-class=" … ? ‘class-1’ : ( … ? ‘class-2’ : ‘class-3’)"> for example :
<div ng-class=“apt.name.length >= 15 ? ‘col-md-12’ : (apt.name.length >= 10 ? ‘col-md-6’ : ‘col-md-4’)”> … </div> And make sure it’s readable by your colleagues :)
angular-ng-class-if-else-expression
不过样式不是太会写 if-else-expression
html中的写法,怎么让a 标签给隐藏呢
<td>
<a ng-class="job.Status === 'Running' ? '' : 'btn btn-primary btn-xs'" ng-click="vm.stopJob(job.id)">
<i></i> Stop
</a>
</td>
a ng-class=“job.Status === ‘Running’ ? ‘btn btn-primary btn-xs disabled’ : ‘btn btn-primary btn-xs’” ng-click=“vm.stopJob(job.id)”>
不显示,最直接的方法: ng-show=“job.Status === ‘Running’”
@jnuc093 互相帮助嘛