【发布时间】:2016-01-12 10:54:03
【问题描述】:
我正在构建一个指令,它应该采用 html 文件,将其放在 dom 中并使用 angular 的 compile 对其进行编译
我收到一个错误:
$templateRequest 不是函数
显然我做错了什么,不知道是什么,
这是我的指令:
module Uni.Directives {
export class uniTable implements ng.IDirective {
public restrict: string = 'EA';
public link: Function = (scope: ng.IScope,
$templateRequest: ng.ITemplateRequestService,
$compile: ng.ICompileService,
element: ng.IAugmentedJQuery,
attrs: ng.IAttributes) => {
$templateRequest("template.html",false).then(function (html) {
var template = angular.element(html);
element.append(template);
$compile(template)(scope);
});
}
}
angular
.module('TModule')
.directive('uniTable', [() => { return new Uni.Directives.uniTable() }]);
// ******** End adding to module **********
}
【问题讨论】:
标签: angularjs angularjs-directive typescript