angularjs - Not getting returned array of data from factory -


I am calling two different firebase locations to get data, once the data is loaded, I I am creating an object. Then press this object in an array and returning array.

But I am not able to find an operator who is returned from the factory > myApp.factory ('MybetFactory', ['$ firebase', function ($ firebase) ) {var factory = {}; factory .getUsersBetsProfile = function (userId, callback) {// 1. First Phonebag data var firebaseUsersBetsProfileRef = new Firebase ("https: //x.firebaseio .com / profile"). child (userId) ); var UserBeitEvent = []; var Usbet Profile = $ Firebase (Firebase userbutfufferf). $ asObject (); // 2. Once the object calls the second location loads and the Data Usbet profile gets loaded. D $ (load) () (function () {angular.forEach (userBetProfile, function (eachUserBetProfile) {if (eachUserBetProfile == Null & amp;!! & Amp; everyUserBetProfile.hasOwnProperty ('ID')) {var firebaseEventsResultsRef = new Firebase ("https: //x.firebaseio.com/result/+id"); var resultsFilebanks = $ Firebase (Firebase Events Results Rif). $ ASObject (); // Once the data is loaded Afterwards, press it in the object created above resultFilebats. $ Fill (). Then (function () {console.log ('results bytes loaded for profiles', resultsForProfileBets); Each userbut profile. Results = resultFilebits; // 4. press the same object in array user-generated Event.push (eachUserBetProfile;)) ; }}); }); // Points: This array scope does not return the return user in the batteated event; }; Return factory; }];

This is the reason that your array returns to your return userbased event line Because callbacks work in javascript.

Callback, which are things that look like this,

  doSomethingCool ("stuff", function () {...});   

Usually functions are run once they are completed. When your browser waits for the end of doSomethingCool , then it executes the following code.

In other words, if you have such code:

  doSomethingCool ("stuff", function () {console.log ("hello");}); Console.log ("bye");   

You are probably going to see this output:

  Hello   

To resolve your problem, You need to understand how callbacks work in javascript.

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? -