title: Nested subscriptions in Angular with iteration on first result
body: <p>Since this morning I'm trying to solve a really headache-giving issue.</p>
  
  <p>I'll begin by explaining the (really simple) situation.</p>
  
  <p>I've created Groups, which are composed of a title, and an array of members, only given by their id string.</p>
  
  <p>Now, I want to display these Groups. Simple isn't it ? 
  However, I don't want of course to just display the ids of the members, but the complete informations on users of the groups (such as basically their names...).</p>
  
  <p>So, I have of course a service for getting all Groups, and another for getting a User by its Id.</p>
  
  <p>In React, since I'm not using rxjs, I wouldn't have any problem ; async/awaits and Promise.all would do the trick.</p>
  
  <p>However here, several problems appear while trying to get complete infos (calling the 2 services) before rendering it, as:
  1. I want to get the groups
  2. iterate on it
  3. iterate on group members
  4. finally for each member get its id. Therefore each group could have a groupcompleteusers array for example, that i would fill each time I would be getting the info on the users from the id...</p>
  
  <p>So I tried the following: <br />
  - first I tried to play with async/awaits, Promises, but since I'm calling services returning Observables, I'm a bit lost. <br />
  - then I tried to have nested subscriptions. However, I'm completely unable to write it properly, as I'm not only iterating on groups, but also on group.members (which is not existing at the time of the nested subscription, as group is at that time an Observable...)</p>
  
  <p>So, with angular 7/rxjs 6, I tried the following : </p>
  
  <pre><code>getGroups(){
  this.groupsService.getGroups().pipe(
    flatMap(group =&gt; 
      {
        for(let member of group.members){
          this.userService.getUser(member);
        }
      }
      )
  ).subscribe(u =&gt; this.groups = u)
  
  
  }
  </code></pre>
  
  <p>Of course, it's not working, especially as group.members doesn't exist at that time...</p>
  
  <p>So I'm a bit stuck.</p>
  
  <p>Maybe some have a clue?</p>
  
  <p>Thanks!</p>