#angular-lazy-loader
AngularJS lazy loading directive for lazy loading images and videos(via iframe).
A 1 kB minimalistic and lightweight AngularJS directive to lazy load images, background images, and iframes.
npm install angular-lazy-loader
http://tarun-dugar.github.io/angular-lazy-loader/
-
Include angular-lazy-loader.min.js after the angularjs library.
-
Or, you can use
require
:var lazyLoader = require('angular-lazy-loader');
-
Add the 'angular-lazy-loader' module to your app as follows:
angular.module('yourApp', ['angular-lazy-loader'])
-
Add the attribute (directive) 'angular-lazy-load' to the HTML element within which you want to lazy load images and iframes:
<div angular-lazy-load> </div>
-
Optionally, set the threshold attribute that accepts a pixel value to load the asset when it is 'threshold' pixels away (vertically) from the viewport.
<div angular-lazy-load threshold="200"> </div>
-
Replace 'src' attribute of 'img', 'iframe', and 'div' tags with 'data-src':
<img data-src="<your_url>" />