I\'d like to use a property on my ViewModel to toggle which icon to display without creating a separate computed property of the inverse. Is this possible?
When using an observable in an expression you need to access it as a function like:
visible: !charted()
You could use my switch/case binding, which includes case.visible
and casenot.visible
.
<tbody data-bind="foreach: periods">
<tr>
<td data-bind="switch: true">
<i class="icon-search" data-bind="case.visible: $else, click: $parent.pie_it"></i>
<i class="icon-remove" data-bind="case.visible: charted, click: $parent.pie_it"></i>
</td>
</tr>
</tbody>
You could also have it as
<i class="icon-search" data-bind="casenot.visible: charted, click: $parent.pie_it"></i>
<i class="icon-remove" data-bind="case.visible: $else, click: $parent.pie_it"></i>