How can I do this without the multiple ng-if
s?
<h3 ng-if="data.link"><a href="{{data.link}}">{{data.name}}</a></h3>
<h3 ng-if="!data.link"><em>{{data.name}}</em></h3>
I've also considered ng-switch
, but that requires an extra container element which I don't like.
Also tried tertiary expressions (e.g. {{data.link?'option 1':'option 2'}}
) but that looks messy and it doesn't do well with HTML. ng-bind-template
escapes HTML chars and also looks messy.
What's the best way to do this?