JSFiddle - React, Tailwind, and code Playground
HTML
<ul data-bind="foreach: products">
<li>
<span data-bind="text: name"></span>
<button data-bind="click: $parent.remove">Remove</button>
</li>
</ul>
<button data-bind="click: add">Add New </button>
JavaScript
var product = function (data) {
var self = this;
self.name = ko.observable(data);
}
var vm = function () {
var self = this;
self.remove = function (item) {
self.products.remove(item);
};
self.add = function () {
self.products.push(new product("new product"));
}
self.products = ko.observableArray();
}
var viewModel = new vm();
viewModel.products([ new product("product a"), new product("product b")]);
ko.applyBindings(viewModel);