简体   繁体   中英

How to display infinity symbol in AngularJS

I want to conditionally display a value or an infinity symbol in my Web Page.

I wanted to do something like this ..

<td class="rs-table-text" ng-if="batch.est_completion_time ">{{batch.est_completion_time}}</td>

That is if batch.est_completion_time is not empty then display whatever is coming from json .

And the json looks like :

{
  "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":"&infin;",
  "completion_status": "42"
}

But it does not display the infinity symbol. Rather , it displays the &infin; text only. it does not display the infinity symbol. Rather , it displays the &infin; text only.

How to achieve the same ?

In your controller, prepare the data as following :

$scope.est_completion_time = $sce.trustAsHtml(batch.est_completion_time);

In your HTML, you can display it as it is. Don't forget to add ng-bind-html in the outer DOM element.

Adding only ng-bind-html can do the job :

ng-bind-html="batch.est_completion_time"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM