How Would I Convert My New Object Data I Am Retrieving From Firebase Into The Json Form As I Had Before
I just set up my Firebase, angularFire database with my Yeoman, AngularJS app. I use to hard code my data before like so $scope.data = [ { name: 'NAME', description: 'DESCRIPT
Solution 1:
According to this url: Object to array - quick conversion
You need to assign the firebase object to a variable:
$scope.firebaseObj
and then you can stuff it into your $scope.data object by:
$scope.data = [];
for (var i = 0; i < $scope.firebaseObj.length; i++) {
$scope.data[i]['name']= $scope.firebaseObj[i].name;
$scope.data[i]['description']= $scope.firebaseObj[i].description;
$scope.data[i]['type'] = $scope.firebaseObj[i].type;
$scope.data[i]['etc1'] = $scope.firebaseObj[i].etc1;
$scope.data[i]['etc12'] = $scope.firebaseObj[i].etc2;
.
.
.
}
This only will work if every element in the JSON has the same attributes
Post a Comment for "How Would I Convert My New Object Data I Am Retrieving From Firebase Into The Json Form As I Had Before"