Reputation: 16651
The following will show an integer if set, and "-" if not set:
{{ movie.agemin || "-" }}
Now I would like to extend this to show the integer followed by " years" if set, or "-" if not set.
{{ movie.agemin + " years" || "-" }}
However, this now stops executing the or case and always adds " years" at the end, no matter the value.
How does this have to be changed to work correctly?
Upvotes: 1
Views: 38
Reputation: 4870
Try this
<div ng-show="movie.agemin">{{ movie.agemin + " years"}}</div>
<div ng-hide="movie.agemin">-</div>
instead of div, you can use ant html tag
Upvotes: 0