Convert Number to Explanation

I’ve got a table that is repeating data from a database. One of the columns has a number value that is a representation of a word, in this case a status of either “On” or “Off”. I cannot seem to figure out how to format/convert the number 1 to “On” or 0 to “Off”. I’m sure this is easy, I’m just not seeing it.

Thanks for any help.

You can use either the replace or the ternary operator.

{{your_binding == 0 ? 'Off' : 'On'}}

Teodor, once again, thank you for the help. This works perfectly.


Was wondering if there is a way to display a button to a modal instead of the Off?

{{your_binding == 0 ? '<button id="btn1" class="btn btn-primary btn-sm" dmx-on:click=";">View</button>' : 'On'}}

Try this:

{{your_binding == 0 ? '' : 'On'}}
<button id="btn1" class="btn btn-primary btn-sm" dmx-show="your_binding == 0" dmx-on:click=";">View</button>