I am currently working on saving data from multiple sections within my webapp. One section involves storing employee information, while the other deals with employer group information. However, when I save this data in Firebase, it all gets organized by ID, making it difficult to differentiate between the two groups. What I would like is for all data to be categorized into two distinct sections: 'employee' and 'group'. The code snippet below pertains to the employee data controller, but with 'employee' replaced by 'group'.
.controller('GroupsCtrl', ['$scope', 'groupsService', function
( $scope, groupsService, $firebase ) {
$scope.newGroup = {
name: '',
date: ''
};
$scope.data = {};
$scope.data.groups = groupsService.getGroups();
$scope.addGroup = function(newGroup) {
groupsService.addGroup(newGroup);
$scope.newGroup = {
name: '',
date: ''
};
};
$scope.updateGroup = function (id) {
groupsService.updateGroup(id);
};
$scope.removeGroup = function(id) {
groupsService.removeGroup(id);
};
}])
This is how I envision the structured layout:
{
Groups:[
"-JcFXid1A2G8EM7A_kwc" : {
"name" : "hi",
"date": "02/13/91"
},
"-JcFZP5FNtL4Yj6nja_7" : {
"name" : "hi"
"date": "02/13/91"
},
"-JcFtGoZL7J-CCIjTYcL" : {
"name" : "dfgdfg",
"date": "02/13/91"
}
]
Employees:[
"-JcFXid1A2G8EM7A_kwc" : {
"name" : "hi",
"date": "02/13/91"
}
]
}
Your insights and suggestions are much appreciated as I continue to learn. Thank you!