I have successfully implemented the following AngularJS directive:
export module Directives {
export class PasswordsMatch implements ng.IDirective {
public static Factory(name: string) : ng.IDirectiveFactory {
return () => new PasswordsMatch();
}
require = 'ngModel';
link = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: Attributes): void => {
// wondering how to retrieve the directive name here?
};
}
}
This directive is then registered in another script file as:
class Application {
private app: ng.IModule;
constructor() {
// Controllers
// Directives
this.app.directive('ngPasswordsMatch', Directives.PasswordsMatch.Factory());
}
}
Is there a way to access the directive name inside the link function without having to pass it to the Factory function again (so as to avoid duplication of directive names)?