Reputation: 117
I am saving data from multiple locations in my webapp. For example, I am saving employee information from one page and employer group information from another. When I save the data, I am unable to differentiate between the two groups in my firebase view as it is organized by ID given when the data is created. Instead of by ID first, I would like to organize all of my data into two separate sections either 'employee' or 'group'. The following code is repeated for the employee data controller but with 'employee' substituted for the word '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);
};
}])
And this is how I would like it to be structured:
{
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"
}
]
}
Any advice would be great! I am still learning, Thank you!
Upvotes: 2
Views: 141
Reputation: 117
var ref = new Firebase(FIREBASE_URI + '/groups');
will organize it into the groups sub category.
I figured it out!
Upvotes: 1