Created
November 27, 2013 20:35
-
-
Save Baudin999/7682768 to your computer and use it in GitHub Desktop.
Chrome App Storage, retrieving and saving
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When getting somehting from the chrome storage you | |
// need to keep in mind that these items are returned | |
// as objects compared to the localStorage in the browser | |
// which returns the items als string literals. | |
// In combination with angularJS you need to keep in mind | |
// that you need to apply the result of this async call | |
// the the $scope of the controller. This will trigger | |
// the refresh. | |
// I use the chrome storage sync, but there is also a | |
// chrome storage local. | |
chrome.storage.sync.get('firstName', function(person) { | |
$scope.$apply(function() { | |
$scope.voornaam = person.firstName; | |
}); | |
}); | |
if ($scope.firstName) { | |
chrome.storage.sync.set({ firstName: $scope.firstName }, function(){ | |
console.log('first name saved to storage'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment