Javascript 角度Ui网格条件单元格模板
只要字段值不是空字符串,我就需要在ui网格中显示一个按钮。我尝试使用Javascript 角度Ui网格条件单元格模板,javascript,angularjs,angular-ui-grid,Javascript,Angularjs,Angular Ui Grid,只要字段值不是空字符串,我就需要在ui网格中显示一个按钮。我尝试使用ng if,但它不起作用。以下是“我的网格选项”中的代码: { field: 'ReleaseStatus', width: 125, displayName: 'Release Status', cellTemplate: '<div ng-if="row.entity.ReleaseStatus != """> <button id="editBt
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>'
},
{字段:“ReleaseStatus”,
宽度:125,
displayName:“发布状态”,
单元模板:
'
{{COL_FIELD}}
'
},
如果不使用ng if
,则按钮将显示并工作良好。但是,由于某些记录的字段ReleaseStatus为空字符串,因此该按钮不应出现
非常感谢您的帮助。您应该这样写:
'<div ng-if="row.entity.ReleaseStatus !== \'\'">'
“”
你也可以把ng直接放在你想要隐藏的按钮上
但是要小心使用ng if,因为它每次都会创建一个新的作用域。在“您应该这样写”下没有“示例”。为了使用单引号,我不得不使用转义字符“\”。我想它现在起作用了。