javascript - angularjs firebase app: can't display data -
i starting firebase , angular want display data firebase in browser here code
<!doctype html> <html> <head> <!-- firebase --> <script src="//cdn.firebase.com/js/client/2.2.1/firebase.js"></script> </head> <body> title :<title></title><br> content :<content></content><br> <script type="text/javascript" > var t=document.queryselector('title'); var c=document.queryselector('content'); var ref= new firebase('https://fir-app-4394a.firebaseio.com'); ref.on('child_changed',function(snapshot){ var data=snapshot.val(); console.log("title: " + data.title); console.log("content: " + data.content); t.innerhtml=data.title; c.innerhtml=data.content; }); </script> </body></html>
this data in firebase want display content: " fffff" title: "rfff "
i dont know why there no connection firebase :d
you using firebase legacy sdk. set new one.
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase.js"></script>
and need start app little diferrent. instead of going new firebase
must use firebase.initializeapp(config);
, firebase.database().ref()
ref.
<script> // initialize firebase var config = { apikey: "", authdomain: "", databaseurl: "", storagebucket: "", }; firebase.initializeapp(config); var ref= firebase.database().ref(); </script>
to config
details go new console overview clicking in app name , hit add firebase web app.
Comments
Post a Comment