How to set ‘if’, ‘else’, ‘and’ conditions in knockout js Magento 2?

Spread the love

This post will give you the idea in certain ways to use if else, and condition in knockout JS in Magento 2

If else conditions in KO template

<!-- ko if: myData -->
..if statement goes here
<!-- /ko -->
<!-- ko if: !(myData) -->
..else statement goes here
<!-- /ko -->

If else conditions in KO template with && operator

<!-- ko if: X && Y -->
//your code
<!-- /ko -->

<!-- ko if: X && !Y -->
//your code
<!-- /ko -->

<!-- ko if: !X && !Y -->
 //your code
 <!-- /ko -->

You may also like...

Popular Posts

× How can I help you?