// Initialize Firebase
var config = {
databaseURL: "https://visit-hotels.firebaseio.com",
};
firebase.initializeApp(config);
var app = angular.module("nowtimereal", ["firebase"]);
// this factory returns a synchronized array of nowusers
app.factory("peopleNow", ["$firebaseArray",
function($firebaseArray) {
// create a reference to the database location where we will store our data
var ref = firebase.database().ref('nowusers');
// this uses AngularFire to create the synchronized array
return $firebaseArray(ref);
}
]);
app.controller("NowCtrl", ["$scope", "peopleNow", function($scope, nowPeople) {
$scope.now = nowPeople;
$scope.user = Math.round(Math.random() * 25);
$scope.now.$save({
count: $scope.user
});
}]);
I have the following code, I do not know if I'm doing it wrong or it's a problem, but I want to update the first item in the database.
{
"nowusers" : {
"-L2LfbYxbwXDXiWNpt27" : {
"count" : 13
}
}
}
I am using angularfire
with the method $ save, but it does not work for me I have the following error
Possibly unhandled rejection: Invalid record; could not determine key for [object Object]
Any help? Thank you very much