无法将 AngularJS $templateCache 注入 运行 方法
Unable to inject AngularJS $templateCache into run method
我正在尝试根据此处的文档注入和访问 angular $templateCache 服务:https://docs.angularjs.org/api/ng/service/$templateCache。我也在尝试注入我自己的服务。
var myApp = angular.module('my-app');
myApp.run([$templateCache, 'MyService', function($templateCache, myService) {
var contentPromise = myService.getContent();
contentPromise.then(function(content) {
$templateCache.put('myTemplate', content);
});
}]);
MyService 可以很好地注入,但 $templateCache 不能。我收到以下错误:
ReferenceError: $templateCache is not defined
只是改变
myApp.run(['$templateCache', 'MyService', function($templateCache, MyService) {
改为
myApp.run([$templateCache, 'MyService', function($templateCache, myService) {
我正在尝试根据此处的文档注入和访问 angular $templateCache 服务:https://docs.angularjs.org/api/ng/service/$templateCache。我也在尝试注入我自己的服务。
var myApp = angular.module('my-app');
myApp.run([$templateCache, 'MyService', function($templateCache, myService) {
var contentPromise = myService.getContent();
contentPromise.then(function(content) {
$templateCache.put('myTemplate', content);
});
}]);
MyService 可以很好地注入,但 $templateCache 不能。我收到以下错误:
ReferenceError: $templateCache is not defined
只是改变
myApp.run(['$templateCache', 'MyService', function($templateCache, MyService) {
改为
myApp.run([$templateCache, 'MyService', function($templateCache, myService) {