Hi i have got a bog standard value in here which holds how many products are in the chosen categories.. for some reason it is not letting me data-bind the length of
Categories().Products
The length = 3 and i can see it in Google chrome watch list?
<!-- ko if: Categories().Products.length > 0 -->
<span class="Basket right">
<p data-bind:"value: Categories().Products.length"</p>
<!--/ko-->
Any ideas?
Is the 'Categories().Products' observableArray? If so you should use 'Categories().Products()'
<!-- ko if: Categories().Products().length > 0 -->
<span class="Basket right">
<p data-bind:"value: Categories().Products().length"</p>
</span>
<!--/ko-->
Not sure if you had a typo or not, but you need a colon after ko if
<!-- ko if: Categories().Products.length > 0 -->
<span class="Basket right">
<p data-bind:"value: Categories().Products.length"</p>
<!-- /ko -->
And, like @ilya said, you might need to make Products an observable array too.
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.