IF on href

Hello! I need to add a conditional inside the href, how can I do this? I have two different links that depends on the database value.

Hello,
Use the ternary operator for this:

dmx-bind:href="db_value == 123 ? 'url1.html' ? 'url2.html'"
3 Likes

It's not working...

dmx-bind:href="{{categoria}} == 'LLAMADO DE ASAMBLEA' ? 'url1.html' ? 'url2.html'"

Try this:

dmx-bind:href="categoria == 'LLAMADO DE ASAMBLEA' ? 'url1.html' ? 'url2.html'"

or maybe

dmx-bind:href="{{categoria == 'LLAMADO DE ASAMBLEA' ? 'url1.html' ? 'url2.html'}}"

Tried both of them before but the link won't work, it's like there is no href at all.

Sorry I copied your invalid ternary. :slight_smile:

Try:

dmx-bind:href="{{categoria == 'LLAMADO DE ASAMBLEA' ? 'url1.html' : 'url2.html'}}"
1 Like

Excellent, it worked. But now I have other problem, url1 and url2 has also a db value.

I’m trying this but it is not working:

categoria == 'LLAMADO DE ASAMBLEA' ? 'invoice.php?tipo=llamados&id='{{ID}} : 'invoice.php?tipo=notificaciones&id='{{ID}}

categoria == 'LLAMADO DE ASAMBLEA' ? 'invoice.php?tipo=llamados&id=' + ID : 'invoice.php?tipo=notificaciones&id=' + ID

2 Likes