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

Doesn't load angular-cache in app.run.js #244

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi,

I am attempting to implement angular-cache into an angular 1.4.3 app. We are attempting to use angular-cache version 4.6.0. but everytime we run the app build it produces the following error:

Uncaught Error: [$injector:unpr] Unknown provider: angular-cacheProvider <- angular-cache http://errors.angularjs.org/1.4.3/$injector/unpr?p0=angular-cacheProvider%20%3C-%20angular-cache

The code I am using is as follows:

angular.module("testApp").
        run(init);

    init.$inject = ["user", "angular-cache", "$ionicLoading","$ionicPopup", "$state", "$ionicHistory",
                    "AuthService","StoreHierarchyFactory", "$rootScope", "OrganisationService"];

    function init(user, CacheFactory, $ionicLoading, $ionicPopup, $state,
                   $ionicHistory,AuthService,StoreHierarchyFactory, $rootScope, OrganisationService) {

I have linked to the angular-cache.js file in my index.html document as follows:

<script src="lib/ionic/ionic.bundle.js"></script>
<script src="lib/moment.min.js"></script>
<script src="lib/angular-cache.js"></script>

I am well and truly stumped and almost one laptop down. Do you have any suggestions on how we can crawl over the first hurdle.

Cheers.

jmdobry commented 8 years ago

You need to make angular-cache a dependency of your module, e.g.

angular.module('testApp', ['angular-cache'])
  .run(['CacheFactory', function (CacheFactory) {
    // ...
  }]);