localstorageservice

An angular.js service that gives you a table based localStorage API.
Homepage:
6 people use it
Author: Assets.github.com%2fimages%2fgravatars%2fgravatar-user-420 Zmetser
Submitted by: 537a1fab3e5124dab3d031d781b69037?d=https%3a%2f%2fidenticons.github.com%2f26a2a89d80702bc8e40b9242077812b0 Zmetser

localStorage Service for angular.js

An angular.js module that gives you a table based localStorage API.

Dependencies

Only requires angular.js ~1.0.5

Usage

Inject service to your controller


API

  • setItem

Adds a new item to the table.

Returns the passed data.

If an itemID has not been set, the underlaying storage type'll be an array. Otherwise it's an object.

  • addItem

Alias for setItem

  • getItem

Get item by name or by index if its an array.

Returns the item from storage or null if nothing found.

  • removeItem

Remove item by name or by index if its an array.

Returns the removed item or null if no item found.

  • truncate

Dispose all datas from the current table.


Example

Use with underscore.js

You can grab the whole table set with the $$table internal.


Other dependencies

  • bower to get angular and angular.mocks
  • karma to run tests

Get angular and angular-mocks.

bower install

Run tests

karma start karma.conf.js


Browser support

Since this is not a localStorage polyfill, it supports the browsers localStorage supports.

| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) | | ------------ |:------:|:---------------:|:-----------------:|:-----:|:---------------:| | localStorage | 4 | 3.5 | 8 | 10.50 | 4 |


License

Copyright 2013 Oliver Kovacs

Licensed under the MIT License

comments powered by Disqus
This page was last updated over 3 years ago.