title: Problems with parsing a JSON Array after retrieving from firebase when using ionic-selectable
body: <p>I'm currently developing an App using Ionic 3 and Firebase. I'm using ionic-selectable (you can see my <a href="https://stackblitz.com/edit/ionic-selectable-form-control-7dkjrq" rel="nofollow noreferrer">stackblitz here</a>) for the user to select an option from my firebase database array and return the selected option to the user's id.</p>
  
  <p>I have got everything to work, except that ionic-selectable is not reading the retrieved array form firebase.</p>
  
  <p>I'm retrieving the array using the following code:</p>
  
  <pre><code>    this.itemsRefdiag = afg.list('medicalhx');
      this.items = this.itemsRefdiag.snapshotChanges().map(changes =&gt; {
          return changes.map(c =&gt; ({ ...c.payload.val() }));
      });
      const dgRef = this.afg.database.ref();
      dgRef.child('medicalhx').orderByChild('name').on('value', snapshot =&gt; { this.snapshot2 = JSON.stringify(snapshot).replace(/"[0-9]":{"name":|{|}/g, ""); })
  </code></pre>
  
  <p>My console.log results in:</p>
  
  <pre><code>"Hyperthyroidism","Hypothyroidism","Diabetes Type 1","Diabetes Type 2"
  </code></pre>
  
  <p>However, when using ionic-selectable for <code>private diagnoses: Diagnosis[] = [this.snapshot2]</code>, I get 'undefined' options. However, when I manually type in <code>private diagnoses: Diagnosis[] = ["Hyperthyroidism","Hypothyroidism","Diabetes Type 1","Diabetes Type 2"]</code>, it works. I also tried parsing the JSON array using the following code instead:</p>
  
  <pre><code>this.itemsRefdiag = afg.list('medicalhx');
      this.items = this.itemsRefdiag.snapshotChanges().map(changes =&gt; {
          return changes.map(c =&gt; ({ ...c.payload.val() }));
      });
  const dbRef = this.afg.database.ref();
  dbRef.child('medicalhx').orderByChild('name').on('value', snapshot =&gt;
  {     let snapshot3 = JSON.stringify(snapshot).replace(/"}/g, `"`);
  let snapshot4 = snapshot3.replace(/"[0-9]":{"name":|{|}|"/g, "");
  this.snapshot2 = snapshot4.split(",");
    });
  </code></pre>
  
  <p>My console.log results in an Object with separate strings (an array):</p>
  
  <pre><code>["Hyperthyroidism","Hypothyroidism","Diabetes Type 1","Diabetes Type 2"]
  </code></pre>
  
  <p>However, ionic-selectable still doesn't seem to read that and I get undefined error. Any ideas on what I may be doing wrong with the array?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>It actually does work the second time around, however the console error pops up the first time and I believe this is because it's not waiting for the array results to pop-up the first time around. Is there a way to add a wait time until the array loads?</p>