1

How to pass option value dynamically in Magento 2 using ko.

web/template/minicart/item/default.html

I want the loop

for(i=0;i<=5;i++){
 <option>i</option>}

But I can able to pass only static value in option

<select data-bind="attr: {
                             id: 'cart-item-'+item_id+'-qty',
                            'data-cart-item': item_id,
                            'data-item-qty': qty,
                            'data-cart-item-id': product_sku
                             }, value: qty">                        
                            <option>1</option>
                            <option>2</option>
                            <option>3</option>
                            <option>4</option>                      
                        </select>

How to do this?If anyone knows that please explain me

1
  • How to find corresponding js file for this template...
    – Maha
    Dec 27, 2017 at 5:10

2 Answers 2

0

Please check given below URLs to understand the concept of the knockout.js

Magento 2 what is use of knockout.js?

http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/translations/translate_theory.html

0
0

You have to create an array and use it in the data-bind.

Please see an example : http://knockoutjs.com/documentation/options-binding.html

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.