<h3>Products</h3> <ul> <li><strong>Here is a static header item</strong></li> <!-- ko foreach: products --> <li> <em data-bind="text: name"></em> <!-- ko if: manufacturer --> — made by <span data-bind="text: manufacturer.company"></span> <!-- /ko --> </li> <!-- /ko --> </ul>
function appViewModel() { this.products = ko.observableArray([ { name: "XBox", manufacturer: { company: "Microsoft" } }, { name: "PlayStation", manufacturer: { company: "Sony" } }, { name: "Banana", manufacturer: null }, { name: "Wii", manufacturer: { company: "Nintendo" } } ]); }; ko.applyBindings(new appViewModel());