How do you console log inside a knockout template

我们两清 提交于 2020-03-17 10:11:16

问题


I thought this was correct:

            <div data-bind="foreach: amount_options, visible: $parent.displayAskAmoutRadioButtons()">
                <!-- ko console.log(amount_option) --><!-- /ko -->
                <label class="donor-js-amount-choice">
                    <!-- <input type="radio" class="donor-js-webware" name="gift_amt" data-bind="attr: {value: key}, checked: $parent.amountSelected"><span class="donor-js-currency-symbol" data-bind="html: $root.session.currencySymbol"></span>&nbsp;<span class="donor-js-input-currency" data-bind="text: desc"></span>&nbsp;<span class="donor-js-input-currency"></span><br> -->
                </label>
            </div>

apparently not as nothing gets out put to the console. The commented out line of tag is throwing an error about the value: key and I need to know whats inside of one of these amount_options.

Ideas?


回答1:


Try this. Knockout should evaluate value for binding and flush to console.

<div data-bind="text: console.log(amount_option)"></div>


来源:https://stackoverflow.com/questions/35109051/how-do-you-console-log-inside-a-knockout-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!