Reputation: 553
How can I set the value of an <input>
to false? true works fine.
Model:
function Model(){
self = this;
self.Test = ko.observable(false);
};
HTML:
<input type="text" data-bind="value:Test"/>
Upvotes: 2
Views: 276
Reputation: 339786
An <input type="text">
expects a text value, and you're supplying a boolean.
The boolean value false
is considering "falsey" when passed in the value attribute, which is the same as supplying no value, so it appears blank.
It works for true
because you end up with true.toString()
Upvotes: 4