มีตัวอย่างของการใช้ TypeScript กับ KnockoutJS หรือไม่? ฉันแค่อยากรู้ว่าพวกเขาจะทำงานร่วมกันอย่างไร
แก้ไข
นี่คือสิ่งที่ฉันมีดูเหมือนว่าจะทำงาน
declare var ko: any;
declare var $: any;
class ViewModel {
x = ko.observable(10);
y = ko.observable(10);
}
$(() => {
ko.applyBindings(new ViewModel());
});
สิ่งนี้จะสร้างเป็น Javascript ต่อไปนี้:
var ViewModel = (function () {
function ViewModel() {
this.x = ko.observable(10);
this.y = ko.observable(10);
}
return ViewModel;
})();
$(function () {
ko.applyBindings(new ViewModel());
});
ko.observable<number>(10)
observables: ฉันเขียนบล็อกโพสต์พร้อมข้อมูลรายละเอียดเพิ่มเติม: ideasof.andersaberg.com/idea/12/…