How to debug in ko template in magento 2?

Debugging

<div data-bind="text: ko.computed(function() { debugger; })"></div>

Print Data

<div data-bind="text: ko.toJSON(method.method_code)"></div>

Docs from Magento: https://devdocs.magento.com/guides/v2.4/ui_comp_guide/troubleshoot/ui_comp_troubleshoot_js.html


There is one another great tool available for debugging knockout js data in chrome browser.

Knockoutjs context debugger

https://chrome.google.com/webstore/detail/knockoutjs-context-debugg/oddcpmchholgcjgjdnfjmildmlielhof?hl=en

Add Knockoutjs context debugger in chrome browser. You can see a new tab added Knockout context at the right panel in Elements tab where you can check knockout data of selected element.

Check Screenshot:

enter image description here