title: Accessing global variable from within method Typescript
body: <p>Hey guys I'm wondering how to access variables from the global scope (this) from within 2 methods. Help appreciated    </p>
  
  <pre><code>location: any;
  
      doSomethingOne() {
      Geolocation.getCurrentPosition().then((resp) =&gt; {
                  this.location = resp;
                  this.doSomething();
  
              }).catch((error) =&gt; {
                  console.log('Error getting location', error);
              });
      }
  
      doSomething() {
          return new Promise(resolve =&gt; {
          this.http.get('http://xxxxxxxxx.xxxx/api/' + this.location.coords.latitude + '/' + this.location.coords.longitude + '/5')
              .map(res =&gt; res.json())
              .subscribe(data =&gt; {
                  this.data = data;
                  resolve(this.data);
              });
      });
      }
  </code></pre>
  
  <p>How can I access this.location from within a Promise? Console shows 'undefined' when accessing it</p>