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.
If your placeholder is not working then it simply means that you have assigned them some value to that input. In your case, I am 100% sure that {{ d. placeholder }} holds some value( might be value equal to ' '). Assign this value to NULL.
Placeholders can be used to enhance the experience of your application. You will, need set some custom widths to toggle their visibility. Their appearance, color, and sizing can be easily customized with our utility classes.
The Placeholder Value enables you to provide a hint text about the values that need to be entered in an input field. On the entry page, this text is visible inside the input area, and disappears once the user starts typing in the field.
Placeholders in sample code and commands represent values that the user must replace when they use the sample input. Placeholders in example output can also represent other values that vary. In general, a placeholder has a descriptive name as a default value.
{{ 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With