Reputation: 105
<input placeholder="{{a}} || zero">
I want to set the placeholder to become 'zero' if the {{a}} is null but that isn't work, it displayed || zero instead.
Upvotes: 1
Views: 288
Reputation: 1698
The right way:
<input placeholder="{{ a || 'zero' }}">
The first step is: Angular calculates the result of the expression inside {{ }}
- a || 'zero'
The second step is: Angular puts the result to the placeholder
In your variant:
The first step is: Angular calculates the result of the expression inside {{ }}
- a
The second step is: Angular puts the result to the placeholder
The third step is: HTML appends || zero
as string to the placeholder
Upvotes: 5