Mark Mark - 2 months ago 4x
HTML Question

Angular ng-if ternary operator in one span?

So am trying to use a ternary operator to combine 2 spans as:

<span ng-if="customer != null">{{ customer }}</span><span ng-if="customer == null">[customer]</span>

The switch is just based on if an id has a value or not in an input elsewhere in the form. Suggestions?

Thanks much.


do you mean something like:

<span>{{ (customer != null) ? customer : '[customer]' }}</span>

could also be written as:

<span>{{ customer || '[customer]' }}</span>