ES6 and variable scope inside a promise
<p>Not sure what I'm missing here.</p>

<p>I need to get the output of <code>data</code> into <code>this.contact</code>. Right now, I'm using a static class variable, but it seems dirty to have to do that.</p>

<pre><code>export class contactEdit {
  static t; // static class var
  constructor() {
    this.id = null;
    this.contact = null;
    contactEdit.t = this;
  }

  activate(id) {
    this.id = id;
    let contact = this.contact; // scoped version of class var
    return dpd.contacts.get(id).then(function(data) {
      console.log(data);
      contactEdit.t.contact = data; // this works
      contact = data; // this doesn't
    });
  }
}
</code></pre>

<p>Normally I would create a <code>var contact</code> inside the <code>activate()</code> function (it works in the Chrome console) but this doesn't seem to working in ES6.</p>

<p>Chrome console:</p>

<pre><code>var c = null;
undefined
c;
null
dpd.contacts.get('a415fdc8f5a7184d').then(function(data) {
      c = data;
    });
Object {}fail: (n)then: (e,t)__proto__: Object
c;
Object {firstName: "John", lastName: "Doe", id: "a415fdc8f5a7184d"}
</code></pre>