Here's the TypeScript code for an Angular directive class I've been working on:
I'm wondering how I can incorporate a controller into this directive without creating a separate controller class. My goal is to write and inject the ISOLATE SCOPE directly within the directive class in 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());
}