Angular translate filter in ternary operator Angular translate filter in ternary operator angularjs angularjs

Angular translate filter in ternary operator


I think if you wrap the ternary operator into (), it will work.

<button> {{ ( conditionValue ? 'Show' : 'Hide' ) | translate }} </button>


you may try for this:

here i make username online and offline when you choose soanish, the user online status will change into spnish based on ternary condition.

https://plnkr.co/edit/o16dpI?p=preview

[https://plnkr.co/edit/o16dpI?p=preview][1]{{ ( userName ? 'Show' : 'Hide' ) | translate }}


I've just come up with the solution!For ternary operators we have to use 'translate' directive instead of filter. And it works just fine:

{  "show_value": "Show",  "hide_value": "Hide",}<button translate> {{ conditionValue ? "show_value" : "hide_value" }} </button>