以下是我迄今为止编写的打字稿中的角度指令类:
我的问题是如何为这个指令添加控制器。我不想创建新的控制器类并将该控制器与控制器绑定。我想编写控制器并将 ISOLATE SCOPE 注入到 typescript 的指令类中
module Sheet.Directive{
class InputControl implements ng.IDirective {
restrict = 'A';
//require = 'ngModel';
templateUrl = "../Templates/inputcontrol.html";
constructor(private $location: ng.ILocationService) {
}
link = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, ctrl: any) => {
console.log(this.$location);
};
static factory(): ng.IDirectiveFactory {
const directive = ($location: ng.ILocationService) => new InputControl($location);
directive.$inject = ['$location'];
return directive;
}
}
angular.module("SheetApp").directive("inputControl", InputControl.factory());
}