【发布时间】:2016-02-24 08:28:34
【问题描述】:
我想使用 $templateCache 服务将一些 html 添加到缓存中。在 Angular 文档示例中,它只显示了在运行中使用它的情况:
var myApp = angular.module('myApp', []);
myApp.run(function($templateCache) {
$templateCache.put('templateId.html', 'This is the content of the template');
});
但是,当我尝试通过 myApp 配置添加一些模板时,似乎存在注入器错误。有没有办法使用不在 RUN 中的 templateCache?
谢谢
【问题讨论】:
-
您是否 100% 肯定您不能在配置中注入 $templateCache?什么是喷油器错误?
-
它的错误:$injector:modulerr 模块错误
-
@mostruash $templateCache 是一项服务,不能注入到配置中。您只能注入提供程序。
-
@hansmaad,所以只能将工厂注入到配置中?
-
@uksz 提供者。为什么要在
config中添加模板?run怎么了?
标签: angularjs angular-templatecache