I've set up a dashboard where I can create lists and have them displayed on the screen, but there seems to be an issue when trying to open any list as only the last created one opens. Can anyone point out what mistake I might be making? The technologies being used are the latest versions of Angular, Firebase, and AngularFire.
In my code snippet below, you'll find functions for creating and opening lists:
allLists = new Firebase('https://url.firebaseio.com/lists/' + authData.uid);
// Function to create a new list using a modal service
$scope.createList = function(){
newList = allLists.push({
name: 'new list'
});
listUID = newList.key();
$rootScope.listUID = new Firebase('https://url.firebaseio.com/lists/' + authData.uid + '/' + listUID);
// Opens ngDialog with specified template
ngDialog.open({
template:'user-modal.html',
controller: 'createController',
scope: $scope,
className:'ngdialog-theme-default'
});
console.log('listUID is: ' + listUID);
return listUID;
};
// Function to open an existing list for editing or deletion
$scope.openList = function(index){
oldUID = new Firebase('https://url.firebaseio.com/lists/' + authData.uid + '/' + listUID);
ngDialog.open({
template: 'user-old-list.html',
controller: 'oldListController',
className: 'ngdialog-theme-default',
scope: $scope
});
console.log(listUID);
};
The simple HTML part looks like this:
<div ng-repeat="(id, lists) in listCounter" class="user-lists">
<button ng-click="openList()" ng-model="listCounter[id]">{{lists.$id}}<br />{{lists.name}}</button>
</div>
This HTML section corresponds to:
$rootScope.listCounter = $firebaseArray(allLists);