-
Notifications
You must be signed in to change notification settings - Fork 1.5k
TypeScript
Dmitry Panyushkin edited this page Oct 10, 2017
·
1 revision
npm install --save-dev @types/knockout
This package provides some type definitions in global namespace.
let name: KnockoutObservable = ko.observable("John");
let upper: KnockoutComputed = ko.computed(() => name().toUpperCase());There are two different libraries for decorators support:
-
npm install --save vt-knockout-decorator -
npm install --save knockout-decorators
These plugins will allow you to be away with parentheses.
@component("person-view", `
<div>Name: <span data-bind="text: fullName"></span></div>
<div>Age: <span data-bind="text: age"></span></div>
`)
class PersonView {
@observable firstName = "John";
@observable lastName = "Doe";
@observable age = 18;
@computed get fullName() {
return this.firstName + " " + this.lastName;
}
}