Skip to content

Instantly share code, notes, and snippets.

@ironfroggy
Created April 26, 2013 19:16
Show Gist options
  • Save ironfroggy/5469666 to your computer and use it in GitHub Desktop.
Save ironfroggy/5469666 to your computer and use it in GitHub Desktop.
app.factory('Doodles', function() {
var Doodles = [
];
return Doodles;
});
app.controller('DoodleListCtrl', function($scope, Doodles) {
var root = angular.element(document.querySelector('[ng-app]')).scope();
$scope.doodles = Doodles;
root.$on('dataReady', function(root, db) {
db.stores.doodles.walk()
.on('each', function(doodle) {
$scope.doodles.push(doodle);
}).then(function(){
if ($scope.doodles.length === 0) {
var doodle = {
created: new Date()
};
$scope.doodles.push(doodles);
db.stores.doodles.put(1, doodle);
}
console.log($scope);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment