I am new to typescript and will like to convert the following Knockout+js to knockout+typescript. The Knockout+js is working, however I am still failing to make it work 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;