Select default project

This commit is contained in:
Max Lynch
2013-10-07 00:50:39 -05:00
parent c47bea49ab
commit 604f5fe8f7

View File

@ -151,7 +151,8 @@ angular.module('ionic.todo.controllers', ['ionic.todo'])
$scope.setActiveProject(np);
};
$scope.projects = angularFireCollection(new Firebase(FIREBASE_URL + '/project_list'), function(snapshot) {
var projectsRef = new Firebase(FIREBASE_URL + '/project_list');
$scope.projects = angularFireCollection(projectsRef, function(snapshot) {
if(!snapshot.val()) {
var title = prompt('Create your first list:');
if(title) {
@ -161,5 +162,12 @@ angular.module('ionic.todo.controllers', ['ionic.todo'])
}
}
});
projectsRef.once('child_added', function(snapshot) {
$scope.setActiveProject(
angular.extend({
'$ref': snapshot.ref(),
}, snapshot.val())
)
});
})