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 in my answer, but I would like to know what other ways there are. Maybe, also for placeholder for promises.
{{ counter || '?'}}
.
Just pure javascript. ||
can be used as default value. Since it would be different empty messages in each, a generalized directive would not be suitable for many cases.
If you want to apply a different class to empty ones, that's also built-in:
<div ng-class="{empty: !counter}" ng-bind="counter || ?"></div>