In my typescript file, I am trying to have an observable class which holds all my UI related fields, which I can then get and post to the server. I have it outisde of my viewmodel, as I want to separate the fields I post, to all the other view model items.
So, in my typescript file, first off, I create my UI model.
interface Model {
id: KnockoutObservable<number>;
}
class MyViewModel {
model: KnockoutObservable<Model>;
constructor() {
$.get("/api/debt/1")
.done((data) => {
this.model().id(data.ID);
});
}
}
This doesn't work. For some reason, 'this.model' is unknown.
Is what I am trying to do even possible? What am I doing wrong?
Edit: Simplified to just use the id property. Using interface, instead of class. Failing on this.model().id(data.ID), as 'mode is not a function). Not sure how to initialise the model now.