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 🙏

© 2024 – Pkg Stats / Ryan Hefner

image-loader-angular

v1.2.0

Published

An AngularJS Factory module that preloads images in your application seperated from template-rendering

Downloads

11

Readme

image-loader-angular

An AngularJS module for loading images to be put in image tags in the markup of application. Using this module to load images will keep remove the responsibility of loading images from the view and thus not block its rendering process. Compatible with AngularJS 1.2.14 up to 1.5.

Installation

Use npm to install the module: npm install image-loader-angular

Or use Bower to install the module: bower install image-loader-angular

Directive

Use the directive as a substitute for the <img> tag. The directive will load the image and insert it into the view markup as an <img> tag. All attributes included in the directive will be added to the tag. First include the ImageLoader module to the app.

// Include the image-loader in your module dependencies
var exampleApp = angular.module('exampleApp',['sap.imageloader']);
<div>
  <loaded-image src="{{ imageSrc }}"></loaded-image>
</div>

Service

Use the service in your AngularJS controller to load your images before inserting them into your view.

Image source is a string

####Controller

// Include the image-loader in your module dependencies
var exampleApp = angular.module('exampleApp',['sap.imageloader']);

exampleApp.controller('ExampleController', ['$scope', 'ImageLoader', function($scope, ImageLoader) {
  var myImageSrc = 'http://someimagesource.com/example.jpg';
  ImageLoader.loadImage(myImageSrc).then(function(loadedSrc) {
    $scope.imageSrc = loadedSrc;
  });
}]);

####View

<div>
  <img ng-src="{{ imageSrc }}" />
</div>

Image source is an object property

####Controller

exampleApp.controller('ExampleController', ['$scope', 'ImageLoader', function($scope, ImageLoader) {
  var myObject = {
    myImageSrc: 'http://someimagesource.com/example.jpg'
  };

  // Second parameter of loadImage is the object key for the image source, default is "src".
  ImageLoader.loadImage(myObject, 'myImageSrc').then(function(loadedObject) {
    $scope.imageObject = loadedObject;
  });
}]);

####View

<div>
  <img ng-src="{{ imageObject.myImageSrc }}" />
</div>

List of image objects or strings

####Controller

exampleApp.controller('ExampleController', ['$scope', 'ImageLoader', function($scope, ImageLoader) {
  var myStringsList = [
    'http://someimagesource.com/example.jpg',
    'http://someimagesource.com/example2.jpg'
  ]

  var myObjectsList = [
    {myImageSrc: 'http://someimagesource.com/example.jpg'},
    {myImageSrc: 'http://someimagesource.com/example2.jpg'}
  ];

  // List of strings
  ImageLoader.loadImages('myStringsList').then(function(loadedStrings) {
    $scope.imageStringsList = loadedStrings;
  });

  // List of objects
  // Second parameter of loadImages is the object key for the image source, default is "src".
  ImageLoader.loadImages(myObjectsList, 'myImageSrc').then(function(loadedObjects) {
    $scope.imageObjectsList = loadedObjects;
  });

}]);

View

<!--Strings-->
<div>
  <img ng-repeat="imageSrc in imageStringsList" ng-src="{{ imageSrc }}" />
</div>

<!--Objects-->
<div>
  <img ng-repeat="imageObject in imageObjectsList" ng-src="{{ imageObject.myImageSrc }}" />
</div>