Pregunta

I have the following code to grab data and view it in the console from a firebase setup, I have no idea why it isn't working. Here is my code below. It is running live at this site if you want to inspect it. Here is a link to a jsfiddle

<!doctype html>
<html lang="en" ng-app="DemoApp">
<head>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  <script type='text/javascript' src='https://cdn.firebase.com/js/client/1.0.11/firebase.js'></script>
   <script type="text/javascript">
var dataRef = new Firebase('https://edengarden.firebaseio.com/test');
dataRef.on('value', function(snapshot) {
  console.log(snapshot.val());
});
</script>
</head>
<body>
</body>
</html>
¿Fue útil?

Solución

If I change your JavaScript to this:

var myDataRef = new Firebase('https://edengarden.firebaseio.com/test');
myDataRef.on('child_added', function(snapshot) {
    var message = snapshot.val();
    console.log(message);
});

It logs a lot of objects, like this:

Object {value: 11}

Object {value: 11}

Object {value: 11}

Object {value: 15}

...

Is that not what you see/expected?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top