arrays - How can I get all objects in Firebase with using AngularJs -


i want objects firebase database getting error. here how tried far;

my firebase db (json);

{ "posts" : { "-kvwh7awrtg04zdtbtkd" : {   "posttext" : "heo1" }, "-kvwhac2skrc_fy75a2i" : {   "posttext" : "heo2" } } 

and here controller;

$scope.loadpost = function() { $scope.posts=$firebasearray(firebasedata.refpost()); } 

and service;

.factory('firebasedata', function($firebase) {  var refpost = new firebase("https://myapp.firebaseio.com/posts");  refpost: function() {   return refpost;  } } }) 

result: error: firebasedata.refpost not function

what wrong suggestion ? thanks

always prefer documentation instead tutorials/blogs/sites...

https://firebase.google.com/docs/database/web/start

first need initialize firebase sdk code snippet in console.

then you create reference father of 'posts' node, this.

      var fatherposts = firebase.database().ref().child('posts');         fatherposts.on('value', function(snapshot){            //finally 'posts' node , send scope           $scope.fatherposts = snapshot.val().posts;          }); 

go documentation , read function 'on' , 'once' https://firebase.google.com/docs/database/web/read-and-write


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -