knockout.js - Using Typescript & Knockout, how do I nest Models? -


i want use models describe data. defining model properties of type knockoutobservable<t>. map data instance of model class. works , in simple case this:

class personmodel extends model {     public name: knockoutobservable<string> = ko.observable<string>("");     public age: knockoutobservable<number> = ko.observable<number>(0); } 

but want nest model inside model so:

class personmodel extends model {     public name: knockoutobservable<string> = ko.observable<string>("");     public age: knockoutobservable<number> = ko.observable<number>(0);     public children: knockoutobservablearray<personmodel> = ko.observablearray<personmodel>([]); } 

in mapping function, how know children personmodel can create instance of each entry? create generic object, i'd lose functionality of model. possible? know how in c#, use activator , create new instance of generic type, is, knowledge, impossible in typescript. i'm racking brain on , appreciate insight possible solutions.


Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -