How to display placeholders in AngularJS for undefined expression values?

后端 未结 5 1685
情歌与酒
情歌与酒 2021-02-02 05:13

If I have an expression {{ x }} and x is undefined or null, then how can I display a placeholder for it?

I provided one solution

5条回答
  •  再見小時候
    2021-02-02 05:56

    I do it with ng-show, like this:

    {{username}}
    N/A
    

    Sure, it adds a lot more elements to my view that I might be able to handle differently. I like though how easy it is to clearly see where my placeholder/empty values are, and I can style them differently as well.

提交回复
热议问题