npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

angular-imgcache.js

v1.2.0

Published

Simple imgcache.js wrapper for AngularJS

Downloads

10

Readme

angular-imgcache.js

Simple imgcache.js wrapper for AngularJS, can be used with Ionic/Cordova/Phonegap.

Installation

Install via bower

bower install --save angular-imgcache.js

Link library and dependencies

<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/imgcache.js/js/imgcache.js"></script>
<script src="bower_components/angular-imgcache.js/angular-imgcache.js"></script>

Load module

angular.module('MyApp', [
    'ImgCache'
])

Usage

Configuration

You can override imgcache.js default options in Angulars config section.

.config(function(..., ImgCacheProvider) {

    // set single options
    ImgCacheProvider.setOption('debug', true);
    ImgCacheProvider.setOption('usePersistentCache', true);

    // or more options at once
    ImgCacheProvider.setOptions({
        debug: true,
        usePersistentCache: true
    });

    // ImgCache library is initialized automatically,
    // but set this option if you are using platform like Ionic -
    // in this case we need init imgcache.js manually after device is ready
    ImgCacheProvider.manualInit = true;

    // If you want to, you can disable the cache.
    // This might be useful to disable it to get rid of CORS issues when
    // developing cordova Applications using a browser.
    ImgCacheProvider.disableCache(true);

    ...

});

If you are using platform like Ionic, you have to init ImgCache manually. Note: you must set ImgCacheProvider.manualInit = true; as in example above.

.run(function($ionicPlatform, ImgCache) {

    $ionicPlatform.ready(function() {
        ImgCache.$init();
    });

});

You can init library manually in other patforms via "deviceready" callback like this:

<body onload="onLoad()">
function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}

function onDeviceReady() {
    ImgCache.$init();
}

(Thx @emps for this note in #1)

Service

Access imgcache.js and its original methods in your components via promise to make sure that imgcache.js library is already initialized

.controller('MyCtrl', function($scope, ImgCache) {

    ImgCache.$promise.then(function() {
        ImgCache.cacheFile('...');
    });

});

Directive

Angular-imgcache.js comes with directive, which first looks into cache for an image. If not present, it downloads the image, then stores in cache and uses it.

We can set src of an image with ic-src attribute.

<img img-cache ic-src="{{imgUrl}}" />

Or set elements background-image with ic-bg attribute.

<div img-cache ic-bg="{{imgUrl}}" ></div>

Contributing

If you have any issues, please feel free to open an issue.

If you want to contribute code, feel free to do that as well! I will be extra happy if you also check you code using jscs and jshint