Seeking assistance in converting a Knockout.js code to Knockout with Typescript. The current Knockout.js code is operational, but I am encountering difficulties in integrating it with Typescript...
View:
<select data-bind="options: choices, value: selectedChoice"></select>
Model:
var MyModel = {
choices: ["Blue", "White", "Black", "Yellow"],
selectedChoice: ko.observable("Yellow")
};
MyModel.selectedChoice.subscribe(function(newValue) {
alert("the new value is " + newValue);
});
ko.applyBindings(MyModel);
Typescript:
import BaseVM = require("./BaseVM");
class MyModel extends BaseVM {
choices = ko.observableArray(["one", "two", "three"]);
//Here selectedChoice subscribe in typescript...
}
export = MyModel;