Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show a placeholder if value is null in html table using angularjs

I have table that is populating a list using angularjs controller. How can I show a place holder(say a dash sign) if the place expression is null or undefined??

Here is a snippet.

enter image description here

I am populating the view as:

<td>{{trans.Status}}</td>
<td>{{trans.PaymentId}}</td>
<td>{{trans.TransId}}</td>

I found about ng-show in angular docs. But I really don't want to use an extra span under td as this

<span class="empty" ng-show="!trans.TransId">N/A</span>

Is there any better way to do this.

like image 236
Shri Avatar asked Mar 16 '23 04:03

Shri


1 Answers

You can do the following:

<td>{{trans.Status}}</td>
<td>{{trans.PaymentId}}</td>
<td>{{trans.TransId || 'N\A'}}</td>
like image 167
GPicazo Avatar answered Mar 26 '23 02:03

GPicazo