title: Error - firestore is not defined (Only after "then")
body: <p>I have a problem : When I want to create fake users in my database, everything work like a charm until I start the loop 'for'.</p>
  
  <p>At this point, I have this error :</p>
  
  <blockquote>
    <p>Error adding document:  TypeError: Cannot read property 'firestore' of
    undefined</p>
  </blockquote>
  
  <p>I've try multiple things but nothing work ... Do you have an idea ?</p>
  
  <p>Thank you all !</p>
  
  <pre><code>create_NewUser(data:any){
          this.firestore.collection('Users-test').add({
            name:data.name,
            town:data.town,
            gender:data.gender,
            email:data.email,
            picture:data.picture,
            birthdate:data.birthdate
          })
          .then(function(docRef) {
            // console.log("Document written with ID: ", docRef.id);
            let nbInterest:any = data.interests.length;
            // let nbAvailaibilities:any = data.interests.length;
            for (let index = 0; index &lt; nbInterest; index++) {
              this.firestore.collection('Users-test').doc("/" + docRef.id + "/interests/" + index).add({
                interest:data.interests[index]
              }) 
            }
          })
          .catch(function(error) {
              console.error("Error adding document: ", error);
          });
        }
  </code></pre>