这是我习惯用角度指令做的一件事
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 依赖项注入到登录指令中。我将如何将此指令重写为组件?(记住我希望在 templateUrl 上使用 $templateCache)