Unknown provider: $angularCacheFactoryProvider

669 views
Skip to first unread message

Thomas M

unread,
Nov 27, 2013, 10:12:49 AM11/27/13
to angula...@googlegroups.com
Hi Jason, cannot wait to try your library.

However when I follow your set up quide, section "Tell $http to use a cache created by $angularCacheFactory for a specific request:" I get a "Unknown provider: $angularCacheFactoryProvide" error.

I have followed your example line by line and this is roughly what it's like:

var module = angular.module("myModule", []);

module.service('searchService', function ($http, $angularCacheFactory) {

    $angularCacheFactory('dataCache', {
        maxAge: 90000, // Items added to this cache expire after 15 minutes.
        cacheFlushInterval: 600000, // This cache will clear itself every hour.
        deleteOnExpire: 'aggressive' // Items will be deleted from this cache right when they expire.
    });

    return {
        getSearchResults: function (url) {
            var deferred = $q.defer(),
                start = new Date().getTime();
            $http.get(url, {
                cache: $angularCacheFactory.get('dataCache')
            }).success(function (data) {
                console.log('time taken for request: ' + (new Date().getTime() - start) + 'ms');
                deferred.resolved(data);
            });
            return deferred.promise;
        }
    };
});

Then in my controller Im injecting the
searchService and using it.

Nothing else - very simple - I have included the js file (angular-cache.js 2.1.1, after the angular.js include).

Do you have any idea what it could be? it's probably the simplest thing...

Thank you, Thomas

Peter Smith

unread,
Dec 9, 2013, 5:55:48 AM12/9/13
to angula...@googlegroups.com
Thomas, You need to delare the dependency for angular-cach 

var module = angular.module("myModule", ['jmdobry.angular-cache']);

Peter
Reply all
Reply to author
Forward
0 new messages