以下は、これまでに作成した typescript の angular ディレクティブ クラスです。
私の質問は、このディレクティブにコントローラーを追加する方法です。新しいコントローラークラスを作成して、そのコントローラーをコントローラーにバインドしたくありません。typescriptでコントローラを書き、ディレクティブクラス内にISOLATE SCOPEを注入したい
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());
}