[英]AngularJS typescript export class from module error
I have an angular with typescript application and the next situation: 我在打字稿应用程序和下一种情况下遇到了麻烦:
generics.ts: generics.ts:
module app.generics{
export class BaseClass{
someMethod(): void{
alert("doSomeMethod");
}
}
}
homeController.ts: homeController.ts:
module app.home{
class HomeController : generics.BaseClass{
callSomeMethodBase(): void{
this.someMethod(); // from base class
}
}
}
angular.module('app').controller('homeController', HomeController);
So i have 2 different files with two modules and I want to use the class from one module into another file and I get an error: 所以我有2个不同的文件和两个模块,我想从一个模块使用该类到另一个文件,我得到一个错误:
Cannot read property 'BaseClass' of undefined 无法读取未定义的属性“ BaseClass”
So how can I inherit using the class from another typescript module? 那么如何从其他打字稿模块继承使用该类?
Ok so I have never used the module system provide by TypeScript but I think you have to import your module (maybe ?). 好的,所以我从未使用过TypeScript提供的模块系统,但我认为您必须导入模块(也许是?)。
Maybe those links can help you ! 也许这些链接可以帮助你!
https://stackoverflow.com/a/18556583/5542588 https://stackoverflow.com/a/18556583/5542588
http://www.typescriptlang.org/Handbook#modules-splitting-across-files http://www.typescriptlang.org/Handbook#modules-splitting-across-files
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.