title: AngularFirestore database, HTML table not updating when data changed using "onSnapshot"
body: <p>I'm using the <a href="https://firebase.google.com/docs/firestore/query-data/listen#events-local-changes" rel="nofollow noreferrer">onSnapshot</a> to get realtime updates in the database.</p>
  
  <p>I get the data for the table using this code:</p>
  
  <p><strong>Service.ts</strong></p>
  
  <pre><code>export class ExtractorService {
  
    constructor(private fstore: AngularFirestore) { }
  
    sampleFunction() {
      return new Promise(resolve =&gt; {
        this.fstore.firestore.collection('banned').doc('words')
        .onSnapshot(function(doc) {
          //console.log("from service (WORDS): ", doc.data().cars)
          resolve(doc.data().cars);
        }); 
      });
    } 
  </code></pre>
  
  <p>To get the data on the service I use this code for the <strong>Component.ts</strong></p>
  
  <pre><code>export class sampleComponent implements OnInit {
  
  banWords = [];
  
    constructor(private extractorService: ExtractorService) {}
  
    ngOnInit() {
      this.loadBannedWords()
    }
  
   loadBannedWords(){
        this.extractorService.sampleFunction().then(data =&gt; {
        this.banWords = (data as unknown as string[]);
        console.log("words: ", this.banWords )
      })
  
    }
  </code></pre>
  
  <p>Then I load the table using this <strong>HTML</strong>:</p>
  
  <pre><code>&lt;tr *ngFor ="let item of banWords ; index as i "&gt;
        &lt;td&gt;{{ i+1 }}&lt;/td&gt;
        &lt;td&gt;{{ item }}&lt;/td&gt;
  </code></pre>
  
  <p>Then my <strong>database</strong> is look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/pULgN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pULgN.png" alt="enter image description here"></a></p>
  
  <p>The issue here is when I add,update or delete data on the database, the table was not updated or reloaded automatically. I need to refresh the page in order for the table to be updated.</p>
  
  <p>How can I make the table update when the database was updated?</p>