-
StackOverflow 文档
-
TypeScript 教程
-
使用 AngularJS 的 TypeScript
-
简单的例子
export function myDirective($location: ng.ILocationService): ng.IDirective {
return {
link: (scope: ng.IScope,
element: ng.IAugmentedJQuery,
attributes: ng.IAttributes): void => {
element.text("Current URL: " + $location.url());
},
replace: true,
require: "ngModel",
restrict: "A",
templateUrl: templatesUrl.myDirective,
};
}
// Using slug naming across the projects simplifies change of the directive name
myDirective.prototype.slug = "myDirective";
// You can place this in some bootstrap file, or have them at the same file
angular.module("myApp").
directive(myDirective.prototype.slug, [
Templates.prototype.slug,
myDirective
]);