Angular ui-grid 显示HTML unicode字符
Angular ui-grid Display HTML unicode character
我正在尝试在 ui-grid 单元格中显示 HTML unicode 字符(复选标记或 X),其中值分别为 true 或 false。我能够使用 ng-switch 在 table 中执行此操作,如下所示:
<div ng-switch="company.bitReleased">
<div ng-switch-when="true">
<span style="color:green; font-size:x-large" ng-bind-html="company.bitReleased | applyMarks | trustedhtml"></span>
</div>
<div ng-switch-when="false"><span style="color:red; font-size:x-large" ng-bind-html="company.bitReleased | applyMarks | trustedhtml"></span></div>
</div>
使用以下过滤器:
app.filter("applyMarks", function () {
return function (input) {
if (input == true) {
return '✔';
}
else {
return '✘'
}
};
});
app.filter('trustedhtml', function ($sce) {
return $sce.trustAsHtml;
})
我找到了几个在网格单元格中呈现 HTML 的示例,但我无法让它们中的任何一个为我的解决方案工作。
我尝试使用以下方法,但它不起作用:
cellTemplate: '<div> ng-bind-html="row.entity[col.field] | applyMarks | trustedHtml"</div>'
有谁知道这是否可行?非常感谢任何帮助。
ng-bind-html是一个指令,指令需要绑定到一个元素,下面的不行吗?
'<div><span ng-bind-html="row.entity[col.field] | applyMarks | trustedHtml"></span></div>'
我正在尝试在 ui-grid 单元格中显示 HTML unicode 字符(复选标记或 X),其中值分别为 true 或 false。我能够使用 ng-switch 在 table 中执行此操作,如下所示:
<div ng-switch="company.bitReleased">
<div ng-switch-when="true">
<span style="color:green; font-size:x-large" ng-bind-html="company.bitReleased | applyMarks | trustedhtml"></span>
</div>
<div ng-switch-when="false"><span style="color:red; font-size:x-large" ng-bind-html="company.bitReleased | applyMarks | trustedhtml"></span></div>
</div>
使用以下过滤器:
app.filter("applyMarks", function () {
return function (input) {
if (input == true) {
return '✔';
}
else {
return '✘'
}
};
});
app.filter('trustedhtml', function ($sce) {
return $sce.trustAsHtml;
})
我找到了几个在网格单元格中呈现 HTML 的示例,但我无法让它们中的任何一个为我的解决方案工作。
我尝试使用以下方法,但它不起作用:
cellTemplate: '<div> ng-bind-html="row.entity[col.field] | applyMarks | trustedHtml"</div>'
有谁知道这是否可行?非常感谢任何帮助。
ng-bind-html是一个指令,指令需要绑定到一个元素,下面的不行吗?
'<div><span ng-bind-html="row.entity[col.field] | applyMarks | trustedHtml"></span></div>'