I’ve encountered this Knockout code and I’m confused about what the below code is performing:
<!-- ko if: $parent.name == name -->
<a data-bind='text: name'></a>
<!-- /ko -->
Shouldn’t this code be interpreted as a comment?
Reading the documentation:
http://knockoutjs.com/documentation/custom-bindings-for-virtual-elements.html
this looks like a custom binding?
It’s a knockout conditional comment. The HTML inside the comment block is only executed if the code validates to true. Knockout can read and process this comment for you. You don’t have to do anything special. Simply supply the conditional and make sure the variables you reference do in fact exist. Then sit back and let knockout do the rest.