1
// 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
    });

}]);

Tengo el siguiente codigo, no se si lo estoy haciendo mal o es un problema, pero quiero actualizar el primer item de la base de datos.

{
  "nowusers" : {
    "-L2LfbYxbwXDXiWNpt27" : {
      "count" : 13
    }
  }
}

estoy usando angularfire con el metodo $save, pero no me funciona tengo el siguiente error

Possibly unhandled rejection: Invalid record; could not determine key for [object Object]

Alguna ayuda? Muchas gracias

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.