knockout.js - using knockout to set css class with an if condition -
i want set bootstrap css class span if condition (up binded value). have isapproved
field in list , want see field 'label-success' class when active , 'label-important' class when inactive
i added line , time taking first class :
data-bind="text: isapproved, css: isapproved = 'true' ? 'label label-important' : 'label label-important'"
is possible in html or should add computed field on vm?
if understood right, binding looking for.
data-bind="text: isapproved, css: { 'label' : true, 'label-success' : isapproved(), 'label-important': !isapproved() }"
i hope helps.
Comments
Post a Comment