I am new to Javascript and TypeScript and I am wondering if it is possible to do some kind of dependency injection (maybe using require.js)
I have two classes in same module
module MyWebApp {
export class ViewRouter {
... some class methods
}
}
module MyWebApp {
export class MyViewModel{
private router: ViewRouter;
constructor(router:ViewRouter router) {
this.router = router;
}
}
}
Every time I need MyViewModel I have to instantiate ViewRouter
var vm = new MyViewModel(new ViewRouter());
Is there any way around this? I thought that Require.js could help me solve my problem but I don't know how to use it with TypeScript.
Thank you.