JSFiddle - React, Tailwind, and code Playground
by pradeep777
HTML
<p>First name: <input type="text" data-bind="value: name" /> </p>
<p>Last name: <input type="text" data-bind="value: lastName" /></p>
<button data-bind="click: getName">Get name</button> <!-- working correctly -->
<hr />
TypeScript
class Client {
name: KnockoutObservable<string>;
lastName: KnockoutObservable<string>;
getName() {
return alert(this.name()); //working correctly on the view
}
//constructor(name:string, lastName:string) {
constructor() {
this.name = ko.observable("");
this.lastName = ko.observable("");
}
}
var a = new Client();
console.log(a);
ko.applyBindings(new Client());