只要字段值不是空字符串,我就需要在我的 ui-grid 中显示一个按钮。我尝试使用 ng-if
但它不起作用。这是我的网格选项中的代码:
{ field: 'ReleaseStatus',
width: 125,
displayName: 'Release Status',
cellTemplate:
'<div ng-if="row.entity.ReleaseStatus != """>
<button id="editBtn"
type="button"
class="btn btn-default"
data-toggle="modal"
data-target="#myModal"
ng-click="grid.appScope.launch(row)">
{{COL_FIELD}}
</button>
</div>'
},
如果没有 ng-if
,按钮会显示并且效果很好。但是,由于某些记录的 ReleaseStatus 字段为空字符串,因此不应出现该按钮。
非常感谢任何帮助。
最佳答案
你应该这样写:
'<div ng-if="row.entity.ReleaseStatus !== \'\'">'
您也可以将 ng-if 直接放在您要隐藏的按钮上。
但是要小心使用 ng-if,因为它每次都会创建一个新的范围。
关于javascript - Angular Ui-Grid 条件 CellTemplate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37331359/