Conditional operation in ionic

We need to display Create Activity if id is null otherwise display Update Activity.
We are trying
"

({{editid}}!=’’)?“Create Activity” :“Update Activity”

" but it is not working.
Please advise?

Check out:
https://docs.angularjs.org/api/ng/directive/ngIf

<span data-ng-if="(editid != '')" >Create Activity</span>
<span data-ng-if="(editid == '')" >Update Activity</span>

By adding the above lines you will achieve what you asked for :wink:

{{editid ? 'Update Activity' : 'Create Activity'}}
2 Likes

@m13z That’s also a possibility :slight_smile: Seems nicer to me in this situation.

@iwantwin I was actually writing a similar solution to yours, but for just a string it’s simpler to use an expression.

Very true, and both solutions are very worth to mention to increase topic starter’s knowledge :slight_smile: