You're attempting to set a style using the class
attribute, you should be using the css
attribute instead. Use css
instead of style
to avoid issues with IE & Edge. You have also misspelled font-weight
.
<td repeat.for="field of fields"
css="${field.fieldKey == 'validTo' ? 'font-weight: bold;' : ''}">
bold field-text here
</td>
You can also use style.bind
if you prefer the syntax:
<td repeat.for="field of fields"
style.bind="field.fieldKey == 'validTo' ? 'font-weight: bold;' : ''">
bold field-text here
</td>
A good way to have a style set on a particular HTML element when an event happens, is either to
- Set a property on the object, and toggle that property when that event happens. Think of something like
css="${field.bolded ? 'font-weight: bold;' : ''}"
on your HTML element and then setting fields[index].bolded = true
in your viewmodel.
- Reference the HTML element using a
ref
attribute, and toggle the styling directly from the viewmodel. You'd have something like ref="fieldElements[$index]"
, and toggle in the viewmodel: fieldElements[index].style.fontWeight = 'bold'