I am using angular and firebase using angularfire in an app. I have a number of text documents stored in firebase. I want to take all of these documents and return an array of all the paragraphs in these documents for manipulation with angular.
I created a service which syncs the data from firebase with a variable documents. This the service has the following function to change this to an array of paragraphs.
getParas: function(){
var paras = [];
for(var i=0;i< documents.length;i++){
paras = paras.concat(documents[i].text.split('\n'));
}
return paras;
}
However because of the time the data takes to sync from firebase the function returns before the changes have been made to the paras variable.
I've tried using documents.$loaded().then(function(){... but am not sure how to return the result of this from the getParas() function.
I've seen article, but a filter doesn't seem like the best option for this?
Thanks
Matthew