data binding - Set isActive in view model then checkbox is checked -
data binding - Set isActive in view model then checkbox is checked -
i need set true or false each isactive values in view model checkbox checked or not checked in client table. can't implement data-bind alter isactive values
typescript viewmodel:
class modelviewmodel{ products:knockoutobservablearray<product>; constructor() { products = ko.observablearray<product[]>(); } }
typescript model:
class product{ name: knockoutobservable<string>; isactive: knockoutobservable<boolean>; } constructor() { this.name = ko.observable<string>(); this.isactive = ko.observable<boolean>(); }
html:
<table class="table table-bordered"> <tbody data-bind="foreach: vm.products"> <tr> <td><input type="checkbox" id="chekbx" data-bind="value: isactive"></td> <td><span data-bind="text: name"></span></td> </tr> </tbody> </table>
you need utilize different binding, checked
instead of value
.
the "checked" binding.
data-binding knockout.js typescript
Comments
Post a Comment