angularjs - Trying to get child records from Firebase -


angular-Fire-I seeds tutorial stage and messages and to experiment with hair posts, some bizarre reason I do not see While I try to clearly demonstrate them to the children, but in the console it can see while expanding on the parent node. These messages are displayed correctly in HTML, where I have NG-double, so I know that at least the message was baseless.

I thought that cutting off the instruments of an amorphous seed or some children can be put into pieces I returned straight to the firebase

I have it:

  code: ----- var url = fbutil.ref () + "/ message /"; Var ref = new firefighter (url); Var sync = $ firebase (ref) $ AsArray (); Console.log (sync); // It can see me as the appropriate $ firebaseArray object console.log (sync.length); // it shows as 0, although the object above the console.log is length 3 (sink [1]); // displays as unchanged data: ---- message / id1 / text / id2 / text / id2 / post / id3 / text   

You start falling for the common asynchonisity problem.

This is your code snippet:

  var sync = $ firebase (ref). $ AsArray (); console.log (sync); // It can see me as the appropriate $ firebaseArray object console.log (sync.length); // it shows as 0, although the object above the console.log is length 3 (sink [1]); // as undefined   

calls to $ asArray () does not return a firebird array immediately, because data can take some time to get the Firebase server Instead, it gives promise of a firebird array, something that will include your data in the future.

Unless you exit console.log (sync) , the data will be downloaded, so it is (as you say) a proper synchronized array but when < Code> console.log (sync.length) runs the line , the data may not yet be downloaded.

You can wait for the data to be downloaded with $ load () method therefore:

  var sync = $ firebase (referee) ). $ AsArray (); console.log (sync); (Function (sync) {console.log (sync.length); console.log (sync [1]);}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -