Hello.
I wonder if anyone couple help me to loop through this json array with knockout js ?
I can get the parent level for options but i cant get the children level.
thanks
this is a sample of the json
{
"category": [{
"id": 1,
"name": "category name",
"product": [{
"prodId": 1,
"name": "product name",
"options": [{
"optionId": 1,
"name": "Colour",
"colour": [{
"colourId": 1,
"name": "Black"
}, {
"colourId": 2,
"name": "White"
}]
}]
}]
}]
}
this is part of the js file
var self = this;
self.products = productData;
self.chosenProduct = ko.observable( false ); /* The currently-chosen product object */
this is a loop that gets the top level only
<div data-bind="foreach: chosenProduct().options">
<ul>
<li>
<span data-bind="text: name"></span>
</li>
</ul>
</div>
that gives the top level of options. i.e
but i want to print the children of each option under each parent.