D
D
dustik2015-07-19 18:44:36
JavaScript
dustik, 2015-07-19 18:44:36

How can I get different collections from firebase into an array, in an angular controller?

Hello.
I want to get data from two collections of the form into an array:
ff7641048d634623843146eab642c430.png
And display it on the page in the form:

<div ng-repeat="post in vm.allPosts">
       <h3>
             {{ post.postCaption }}
       </h3>
       <p>
            {{ post.postText }}
       </p>
           <span>Автор: {{ post.ownerName }}
               <div ng-repeat="comment in post.comments">
                   <h4>
                       {{ comment.commentText }}
                   </h4>
                   <p>
                       {{ comment.ownerName }}
                   </p>
               </div>
</div>

So far it came up like this:
$q.all( [ getPosts(), getComments() ] ).then(
            function (results) {
                doSomethingOnThem(results[0], results[1]);
            }
        );

Maybe there are better options to immediately get the combined data in an array?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question