admin管理员组文章数量:1327924
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.
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.
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.
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.
Share Improve this question asked Aug 7, 2015 at 16:23 Language LassiLanguage Lassi 2,63022 silver badges25 bronze badges 5- 1 possible duplicate of Angular Template Default Value if Binding Null / Undefined (With Filter) – Tom Pietrosanti Commented Aug 7, 2015 at 16:26
- 1 I think your question is answered here: stackoverflow./questions/16523076/… – Tom Pietrosanti Commented Aug 7, 2015 at 16:26
- Might it be a good idea to give your fields a default value? Or is that impossible dud to further design of the Javascript? – Xyv Commented Aug 7, 2015 at 16:27
- <td>{{trans.TransId || 'N/A'}}</td> – James Brierley Commented Aug 7, 2015 at 16:27
- Thanks @TomPietrosanti those answers what I were looking for. – Language Lassi Commented Aug 7, 2015 at 16:38
1 Answer
Reset to default 8You can do the following:
<td>{{trans.Status}}</td>
<td>{{trans.PaymentId}}</td>
<td>{{trans.TransId || 'N\A'}}</td>
本文标签: javascriptShow a placeholder if value is null in html table using angularjsStack Overflow
版权声明:本文标题:javascript - Show a placeholder if value is null in html table using angularjs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742252860a2441085.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论