Created
April 26, 2013 19:16
-
-
Save ironfroggy/5469666 to your computer and use it in GitHub Desktop.
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
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