【发布时间】:2016-07-02 04:20:23
【问题描述】:
我实现了下一个 AngularJS 指令:
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 => {
// how to get directive name here?
};
}
}
在另一个脚本文件中注册为:
class Application {
private app: ng.IModule;
constructor() {
// Controllers
// Directives
this.app.directive('ngPasswordsMatch', Directives.PasswordsMatch.Factory());
}
}
是否可以在不将指令名称传递给工厂函数的情况下在链接函数中获取指令名称(我不想重复指令名称)?
【问题讨论】:
标签: angularjs angularjs-directive typescript