jmdobry / angular-cache

angular-cache is a very useful replacement for the Angular 1 $cacheFactory.
http://jmdobry.github.io/angular-cache
MIT License
1.39k stars 156 forks source link

CacheFactory undefined #185

Closed MFD3000 closed 9 years ago

MFD3000 commented 9 years ago

Im assuming this is my own user error but after spinning my wheels, I figured id see if anyone is experiencing similar.
Im currently building a hybrid mobile app with ionic.js Im trying to incorporate angular-cache as Ive LOVED using the older version, angularCacheFactory, on a previous project.

However, any time I try and access CacheFactory in my services, its telling me that CacheFactory is undefined.
Ive checked and double checked that the lib is available and injected in app.js and my service properly. I get no errors until I try and use CacheFactory. Even then, I get no error. Im just told CacheFactory is undefined.

Anyone have experience with this issue?

Thanks in advance.

jmdobry commented 9 years ago

Are you coding in ES6? How are you importing angular-cache into your projects?

MFD3000 commented 9 years ago

No Im not using ES6.
Currently Im importing as simply as possible. Have angular-cache.js in libs folder. Loading the script in index.html.

In app.js config, I have injected 'angular-cache'. In my service, which is include in the apps module, I have CacheFactory injected in the function.

jmdobry commented 9 years ago

What version of angular-cache, angular, etc.?

MFD3000 commented 9 years ago

angular v1.3.15

angular-cache 4.2

Here is the one line of code I have trying to access angular-cache right now. var profileCache = CacheFactory('profileCache');

billvolt commented 9 years ago

Try adding CacheFactory as a dependency on your controller:

myControllers.controller('HomeController', ['$scope', '$http', '$routeParams', 'myCache', 'CacheFactory', function HomeController($scope, $http, $routeParams, myCache, CacheFactory) {

jmdobry commented 9 years ago

Should be fixed already, but should be definitely fixed in 4.2.1. See the build_examples.