How do you console log inside a knockout template

2020-06-08 10:30发布

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?

标签: knockout.js
1条回答
欢心
2楼-- · 2020-06-08 10:49

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

<div data-bind="text: console.log(amount_option)"></div>
查看更多
登录 后发表回答