我想在我的网页中有条件地显示一个值或一个无穷大符号。
我想做这样的事情..
<td class="rs-table-text" ng-if="batch.est_completion_time ">{{batch.est_completion_time}}</td>
那是if batch.est_completion_time is not empty then display whatever is coming from json
.
json
看起来像:
{
"batch_queue_name": "Batch Five",
"start_date": "05/01/2017 12:18 A.M.",
"end_date": "08/01/2017 03:37 A.M.",
"est_completion_time":"∞",
"completion_status": "42"
}
但it does not display the infinity symbol. Rather , it displays the ∞ text only.
如何实现相同的目标?
在控制器中,按如下方式准备数据:
$scope.est_completion_time = $sce.trustAsHtml(batch.est_completion_time);
在您的 HTML 中,您可以按原样显示它。不要忘记在外部 DOM 元素中添加ng-bind-html
。
仅添加ng-bind-html
即可完成工作:
ng-bind-html="batch.est_completion_time"