What is the difference between snapping <! - ko & # 8594; and visible knockout binding?

ko <!--ko-->data binding and binding = visible: sometext binding

Both bindings performed the same operation, and which one is efficient to use, and which one is better -

+4
source share
2 answers

<!-- ko [binding] -->allows you to bind to a virtual element .

data-bind="[binding]" is a regular binding and can only be applied to actual elements.

The difference is that the first can be used without creating an element:

<ul>
    <li class="heading">My heading</li>
    <!-- ko foreach: items -->
        <li data-bind="text: $data"></li>
    <!-- /ko -->
</ul>

Note that not every binding handler can be applied to a virtual element:

, , Knockout, , API- ko.virtualElements.allowedBindings.

+4

:

  • , , dom.

.:

<!-- ko visible: prop--><!-- /ko -->
  • , :

.

<table>
    <tbody>
        <tr><td></td></tr>
        <!-- ko if: cond -->
            <tr><td>Optionnal line </td></tr>
         <!-- /ko  -->
    </tbody>
</table>

data-bind:

  • (if, foreach, with) (, , ..).
+6

All Articles