尝试将angular-cache库加载到我的服务时遇到了麻烦。我使用Bower向我的项目添加了角度缓存,并且成功添加了它。当我在Chrome上调试服务代码时,我在“网络”标签中看到已加载角度缓存:
Name: angular-cache.js
Method: GET
Status: 200
Type: script
Initiator: require.js:1901
Size: 6,5 kb
Time: 16 ms
我有一个config.js文件,它加载了所有库。这行是针对角度缓存的:
'angular-cache': '../bower_components/angular-cache/dist/angular-cache',
这是垫片内的线:
'angular-cache': ['angular'],
这是服务:
define(
[ 'angular', 'services-module'],
function(angular, services) {
services.factory(
'MyService',
[
"$location",
"$interval",
"MyOtherService",
"CacheFactory",
function($location, $interval, otherService, cacheFactory) {
var service = {
myCachingFunction : function(parameters){
},
getCache : function(cacheId) {
}
}
return service;
} ]);
});
这是我得到的错误:
Error: [$injector:unpr] Unknown provider: CacheFactoryProvider
这是angular-cache的github页面。我想念什么?
您是否尝试过,我想这是您的service.js:
define(
['angular', 'services-module'],
function(angular, services) {
services.factory(
'MyService',
[
"$location",
"$interval",
"MyOtherService",
"CacheFactory",
function($location, $interval, otherService, cacheFactory) {
在您的app.js中:
define(
['angular', 'angular-cache'],
function(angular) {
var myApp = angular.module('myApp', [ 'ngResource', 'app.controllers', 'app.directives', 'app.services', 'app.filters', 'app.routes', 'app.interceptors', 'angular-cache' ]);
在config.js中:
shim: {
'angular-cache': {
deps: ['angular']
}
}
我猜您正在使用Require with Angular。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句