2

I have html file at the path /var/www/html/nelson-avnet-app/code/vendor/module/view/frontend/web/template/shipping-address/list.html

<!-- ko if: (visible)-->
<div class="field addresses">
 <div class="control">
 <input id="query" type="text" name="query" data-bind="textInput: query, valueUpdate: 'afterkeydown', event: { keyup: check }"/>
 <div class="shipping-address-items">
 <input type="text" data-bind="value: customTotal" />
 <!-- ko foreach: { data: elems, as: 'element' } -->
 <!-- ko if: element.index < customTotal -->
 <h1>show value</h1>
 <!-- /ko -->
 <!-- ko template: element.getTemplate() --><!-- /ko -->
 <!-- /ko -->
 </div>
 </div>
</div>
<!-- /ko -->

if I use if statement as <!-- ko if: element.index < 2 --> Then it works fine but it not work with dynamic value like

<!-- ko if: element.index < customTotal -->

Please help me.

asked Sep 27, 2023 at 14:38

1 Answer 1

0

Do you have customTotal in below js file if not You need to add customTotal variable in js file

vendor/magento/module-checkout/view/frontend/web/js/view/shipping-address/list.js
defaults: {
 template: 'Magento_Checkout/shipping-address/list',
 visible: addressList().length > 0,
 rendererTemplates: [],
 customTotal: 2
 },

You can extend/override this file on your custom module

answered Sep 28, 2023 at 14:25
1
  • I already have customTotal as listed the code below, and its value is 3. But I can not apply condition on html page based on it. defaults: { template: 'Magento_Checkout/shipping-address/list', visible: addressList().length > 0, rendererTemplates: [], customTotal: ko.observable(0), }, Commented Sep 29, 2023 at 14:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.