Registry / storage / angular-localforage

angular-localforage

JSON →
library1.3.8jsnpmunverified

AngularJS service and directive wrapping Mozilla's localForage library for offline storage. Version 1.3.8 is the latest stable release (last published 2016, no updates since). It provides async promise-based storage using IndexedDB, WebSQL, or localStorage fallback. Key differentiators: specifically for AngularJS (1.x), integrates as an Angular module with $localForage service and directive for automatic model persistence. No longer actively maintained; consider modern alternatives like localForage with Angular (2+).

npm install angular-localforage
INSTALL
IMPORT
SIG · ANGULAR-LOCALFORAG
A
angular-localforage
storagejavascriptv1.3.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LocalForageModule
angular.module('myApp', ['LocalForageModule']);
import { LocalForageModule } from 'angular-localforage';
CommonJS/ESM import not supported; use script tags and AngularJS module injection.
$localForage
angular.module('myApp').controller('Ctrl', ['$localForage', function($localForage) {}]);
import { $localForage } from 'angular-localforage';
AngularJS service, injected via dependency injection; not a named export.
local-forage directive
<input local-forage="{key: 'myKey'}" ng-model="data">
<input local-forage option="...">
Directive is an attribute; use object literal syntax with curly braces.

Complete example of storing and retrieving a user object using $localForage service.

<!DOCTYPE html> <html ng-app="app"> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.10.0/localforage.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.3/angular.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-localforage/1.3.8/angular-localForage.min.js"></script> <script> angular.module('app', ['LocalForageModule']) .controller('MainCtrl', ['$scope', '$localForage', function($scope, $localForage) { $scope.save = function() { $localForage.setItem('user', { name: $scope.name }).then(function() { alert('Saved!'); }); }; $scope.load = function() { $localForage.getItem('user').then(function(data) { $scope.name = data ? data.name : ''; }); }; }]); </script> </head> <body ng-controller="MainCtrl"> <input ng-model="name" placeholder="Enter name"> <button ng-click="save()">Save</button> <button ng-click="load()">Load</button> </body> </html>
Debug
Known issues
breakinglocalForage library must be loaded before angular-localForage in script tags.
fix
Ensure <script src='localforage.js'></script> comes before <script src='angular-localForage.js'></script>.
affects: all
deprecatedAngularJS (1.x) is in long-term support; this package is not maintained.
fix
Consider migrating to Angular (2+) with localForage or another modern storage solution.
affects: >=1.0
gotchagetItem resolves with null for non-existent keys; cannot differentiate from stored null.
fix
Use getItem(key, true) to reject the promise when key is not found.
affects: all
gotchaPromise-based API; must handle async with .then() or async/await when using newer AngularJS.
fix
Wrap in $q.when or use $scope.$apply if integrating with non-Angular async code.
affects: all
Errors
Common errors & fixes
Error: [$injector:modulerr] Failed to instantiate module LocalForageModule
Missing localForage library or incorrect script loading order.
fix
Load localforage.js before angular-localForage.js and ensure both are included.
TypeError: Cannot read property 'setItem' of undefined
$localForage service not injected correctly or module not added.
fix
Check that 'LocalForageModule' is listed as a dependency in your Angular module and the service is injected in the controller.
TypeError: localforage is undefined
localForage library not loaded or loaded out of order.
fix
Ensure localforage script tag is present and placed before angular-localForage.
Upgrade
Version history
1.3.8latest on npm
Audit
Dependencies
localforagerequiredBackend storage library for offline data persistence
Agent activity
40 hits · last 30 days
node
34
Resources
angular-localforage — npm install angular-localforage · libregistry