An AngularJS module for chrome.storage, Contains two services $chromeStoreSync
and $chromeStoreLocal
which give access to chrome.storage.sync
and chrome.storage.local
respectively.
###Features
- Two-way binding no need to use getters and setters, storage objects appear as plain old JavaScript objects.
bower install ngChromeStorage
angular.module('app', [
'ngChromeStorage'
]).controller('Ctrl', function(
$scope,
$chromeStoreSync,
$chromeStoreLocal
){});
Pass $chromeStoreSync
and/or$chromeStoreLocal
and attach to scope
$scope.$store = $chromeStoreSync
Use it like a normal javascript object.
<body ng-controller="Ctrl">
<button ng-click="$store.counter = $store.counter + 1">{{$store.counter}}</button>
</body>
here any changes made to $scope.$store
, $chromeStoreSync
andchrome.storage.sync
will automatically be synced this includes changes detected by chrome.storage.onChanged
- Internally changes are detected by using
$rootScope.$watch
so be aware of the potential proformance issues. chrome.storage
is an asynchronous API, and ngChromeStorage gives it a seemingly synchronous interface.chrome.storage.sync
has limitations that you must be mindful of, with ngChromeStorage it is easy to exceed these limits.MAX_WRITE_OPERATIONS_PER_MINUTE
120MAX_WRITE_OPERATIONS_PER_HOUR
1,800QUOTA_BYTES_PER_ITEM
8,192