I have this snippet below in my controller:
var cache = $cacheFactory('contacts');
var data = cache.get('contacts');
if(!data) {
Contacts.get()
.success(function(result) {
data = result;
cache.put('contacts', data);
});
}
My Contacts.get() call returns 152KB of data and is taking ~1.5s to run. I'm trying to cache this data since it does not need to be up to date.
However, every time I refresh the HTTP call is still being made and i'm seeing undefined in the console from logging cache.get('contacts') and data.
How can I cache this data returned from the HTTP call and reference it in the scope?