<h3>Products</h3>
<ul data-bind="foreach: products">
<li>
<strong data-bind="text: name"></strong>
<button data-bind="click: $parent.removeProduct">Delete</button>
</li>
</ul>
function appViewModel() {
var self = this;
self.products = ko.observableArray([
{ name: "XBox" },
{ name: "PlayStation" },
{ name: "Banana" },
{ name: "Wii" }
]);
self.removeProduct = function(product) {
self.products.remove(product);
}
};
ko.applyBindings(new appViewModel());