【发布时间】:2014-01-12 18:35:32
【问题描述】:
我正在尝试将包含控制器的整个类添加到我的指令中,由于某些明显的原因,范围和语法不正确。 我使用 typescript 作为语言,使用 grunt-ts 进行自动生成和编译。
/// <reference path="../reference.ts" />
directives.directive('myDirective', function ():ng.IDirective {
return {
restrict: 'EAC',
template: directiveHTML.html, \\ thanks to grunt-ts this work fine
controller: MyControllerClass, \\ here I get the error and here I would like to
put my own controller class instead of a function
link: function (scope, elements, attrs) {
}
}
});
这里是我的控制器的类
module Controllers {
export class CursorController {
constructor($scope, socket){
}
}
}
然后将所有控制器添加到 angularJS 的控制器模块中(引用由 grunt-td 自动生成)。
/// <reference path="../reference.ts" />
angular.module('controllers',[]).controller(Controllers);
任何有关如何解决此问题的线索或建议都会很棒。
【问题讨论】:
标签: javascript angularjs controller gruntjs typescript