Knockout If-else condition inside html file in Magento 2
You should write a below code for else condition
<!-- ko if: isFreeShipping() -->
//My Code goes here
<!-- /ko -->
<!-- ko ifnot: isFreeShipping() -->
//My Code goes here
<!-- /ko -->
Just to extend a bit on Suresh Chikani's answer to include more combinations under this question:
To do a if-elseif-else construction you would have in PHP:
if (A && B) {
//...code
} elseif (A) { // And thus 'not B'
//...code
} else { // Thus is 'not A' and 'not B'
//...code
}
In Knockout you would do:
<!-- ko if: A && B -->
//...code
<!-- /ko -->
<!-- ko if: A && !B -->
//...code
<!-- /ko -->
<!-- ko if: !A && !B -->
//...code
<!-- /ko -->