Skip to content

Instantly share code, notes, and snippets.

@steinbring
Created August 18, 2014 20:25
Show Gist options
  • Save steinbring/eb3db85786e024224101 to your computer and use it in GitHub Desktop.
Save steinbring/eb3db85786e024224101 to your computer and use it in GitHub Desktop.
How to instantiate the ngStorage module with defaults
// The module
var NotesApp = angular.module('NotesApp', ['ngStorage']);
// The controller
NotesApp.controller('NotesCtrl', function($scope, $localStorage) {
// Set a default
$scope.$storage = $localStorage.$default({
"notes": [{
"title": "What is the notes vault?",
"content": "It is an AngularJS experiment, done by Joe Steinbring. I think it is fairly cool."
}, {
"title": "Things Joe blogs about",
"content": "- Movies\n- Photography\n- Coding"
}]
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment