0
我想在输入框中输入的文本应用于单击按钮上的页面。我正在使用提交绑定,但无法弄清楚我做错了什么。敲击提交绑定点击一个按钮
HTML:
<form data-bind="submit: doSomething">
<label>
<input data-bind='value: showText' />
</label>
<button type="submit">button</button>
</form>
<h1><span data-bind='text: fullText'> </span></h1>
JS:
var ViewModel = function(text) {
this.showText = ko.observable(text);
this.doSomething : function(formElement) {
this.fullText = ko.computed(function(){
return this.showText();
}, this);
}
};
ko.applyBindings(new ViewModel());