I'm trying to import an external class (written in Typescript) into another Typescript class using requireJS. I used this syntax but I don't understand why I'm getting a syntax error with this import statement:
I have also tried using this instead:
import t = module("Controller/TestController");
And I'm also getting the same error.
The above import/require statement resides in appmod.ts
. This is my file structure:
+Root
+Scripts
+app
-main.ts
-appmod.ts
+Controller
-TestController.ts
I have looked through the documentation, and this line looks perfectly fine to me. The file TestController.ts does exist in the path and the classes are prepended with export keyword.
What's wrong with this line?
This is how my TestController.ts look:
/// <reference path="../typings/angularjs/angular.d.ts" />
module testApp.Controller {
export interface ITestScope extends ng.IScope {
helloString:string;
}
export class TestController {
public static $inject = [
"$scope"
];
constructor(private $scope: ITestScope) {
this.$scope.helloString = "Hello!";
}
}
}
I've used DefinitelyTyped's AngularJS definition in my TestController.js.
Your export statement needs to be at the root level in your file. Remove the redundant module http://m.youtube.com/watch?v=KDrWLMUY0R0&hd=1
I.e. Delete 'module testApp.Controller'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With