JSFiddle - React, Tailwind, and code Playground
by nickolsky
HTML
<script src="https://github.com/downloads/SteveSanderson/knockout/knockout-2.0.0.js"></script>
<div data-bind="foreach: customer">
<div data-bind="foreach: filteredOrders(id()) ">
<span data-bind="text: test"></span>
</div>
</div>
JavaScript
var vm = {
customer: ko.observableArray([ {
id: ko.observable(1),
orders: ko.observableArray([ { test: '1', customer: ko.observable(1) },
{ test: '2', customer: ko.observable(2) } ] ),
filteredOrders: function(parentId) {
return ko.utils.arrayFilter(this.orders(), function(o) { return o.customer() == parentId; });
}
}])
};
ko.applyBindings(vm);