title: Angular 2 geolocation
body: <p>I would like to get the geolocation (longitude and latitude) on loading my angular 2 app, and set it to a variable, location. How do I do this? Here is the app.component:</p>
  
  <pre><code>import { Component, OnInit} from '@angular/core';
  @Component({
       moduleId: module.id,
       selector: 'app-root',
       template: `
       &lt;h2&gt;{{location.latitude}}&lt;/h2&gt;
       `
       })
  
  export class AppComponent implements OnInit{
     location = {};
     setPosition(position){
        this.location = position.coords;
        console.log(position.coords);
        }
  ngOnInit(){
     if(navigator.geolocation){
        navigator.geolocation.getCurrentPosition(this.setPosition);
        };
     }
   }
  </code></pre>
  
  <p>When I print position.coords, it comes out. But it does not seem to be setting this.location. Thank you.</p>