I am trying to complete a task where I choose the values of buttons and then using two way data binding I print them. My starting code is:
<table class="table">
<tr>
<td><input type="button" value="1" data-bind="click: addNumber"></td>
<td><input type="button" value="2" data-bind="click: addNumber"</td>
<td><input type="button" value="3" data-bind="click: addNumber"></td>
<td><input type="button" value="4" data-bind="click: addNumber"></td>
<td><input type="button" value="5" data-bind="click: addNumber"></td>
<td><input type="button" value="6" data-bind="click: addNumber"></td>
<td><input type="button" value="7" data-bind="click: addNumber"></td>
<td><input type="button" value="8" data-bind="click: addNumber"></td>
<td><input type="button" value="9" data-bind="click: addNumber"></td>
<td><input type="button" value="10" data-bind="click: addNumber"></td>
</tr>
</table>
and my view model is:
function viewModel(){
var self = this;
self.column = ko.observableArray();
self.addNumber = function() {
self.column.push(...);
console.log(self.column());
}
}
ko.applyBindings(new viewModel());
I don't know how to write the addNumber
function to do the task which is when I click on a button its value gets pushed in the column array.