【发布时间】:2016-09-14 01:45:30
【问题描述】:
这是我习惯使用角度指令的一件事
angular.module('app.directives').directive('login', ['$templateCache', function ($templateCache) {
return {
restrict: 'E',
template: $templateCache.get('directives/login/login.html'),
controller: 'LoginController as vm',
scope: true
};
}]);
我已经非常喜欢使用 模板缓存 在我的指令模板中注入 HTML 内容。现在有了 Angular 1.5,所有酷孩子都在使用这个新东西,叫做 component()在组件本身中注入东西(而不是在控制器中)?
在这种情况下,您可以看到我将 $templateCache 依赖项注入到 login 指令中。我将如何将此指令重写为组件? (记住我希望在 templateUrl 上使用 $templateCache)
【问题讨论】:
标签: javascript angularjs angularjs-components