Conditionally Add Attribute

Viewed 903

Is it possible to conditionally add an attribute to an element using binding syntax? I am aware of if.bind, but that targets elements. Rather I am interested in targeting a specific attribute on an element.

Example:

<a href.bind="model.link">${model.text}</a>

If model.link is falsy, then I don't want the href at all--just treat the <a /> as a container element.

I realize I could create two <a /> tags--one with the attribute and one without--and use an if.bind on both, but that seem clunky and un-aurelia like.

1 Answers
Related