I'm trying to create a large angular app in TypeScript and I want my app layed out with the following folder structure:
./App
--- Controllers
--- --- HomeController.ts
--- --- SomeOtherController.ts
--- Directives
--- --- MyDirective.ts
--- app.ts
I would also like the namespaces/modules to be layed out so all controllers are in the MyApp.Controllers namespace. So in the above example I'd have the 2 controllers in modules:
MyApp.Controllers.HomeController
MyApp.Controllers.SomeOtherController
I set this up doing the following:
HomeController.ts:
export module MyApp.Controllers {
export class HomeController {
...
}
}
SomeOtherController.ts
export module MyApp.Controllers {
export class SomeOtherController {
...
}
}
Now in app.ts I want to import all of my controllers, and this is where I'm running into problems, I try:
import * as Controllers from './controllers/HomeController'
but then to access the controller I have to do:
Controllers.MyApp.Controllers
Which is ugly. Also how do I then get the controller from the other file? Ideally I'd like to import everything in the namespace "MyApp.Controllers" and we able to use it without prefixing MyApp.Controllers in the code.