简体   繁体   中英

knockout foreach is not working for objects in Array

I have an array that has a list of objects and I am trying to loop through it but it seems to not working.

 <:-- ko foreach: applicationsAndProducts --> <p>Apps and Products</p> <ul> <li data-bind="text. applicationsAndProducts.Product"></li> </ul> <!-- /ko -->

applicationsAndProducts has 3 values as below

在此处输入图像描述

You should only be using Product instead of applicationsAndProducts.Product . Check the documentation for foreach binding

<!-- ko foreach: applicationsAndProducts -->
    <p>Apps and Products</p>
    <ul>
        <li data-bind="text: Product">
        </li>
    </ul>
<!-- /ko -->

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM