title: adding result of function into an ionic 2 form field
body: <p>I have built a simple ionic 2 form that submits fine.  But I wish to add the result of a find location function into the form fields.  previously I have used document.getElementByID("lat").value = position.coords.latitude to accomplish this with jQuery forms.  In my code I get my lats and longs variables but now I am trying to figure out how to take the results and input them into the data.lat and data.lng ion-inputs</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;ion-content padding class="formstuff"&gt;
  
    &lt;ion-list&gt;
  
      &lt;ion-item&gt;
        &lt;ion-input type="text" name="lat" placeholder="Latitude" [(ngModel)]="data.lat"&gt;&lt;/ion-input&gt;
      &lt;/ion-item&gt;
  
      &lt;ion-item&gt;
        &lt;ion-input type="text" name="lng" placeholder="Longitude" [(ngModel)]="data.lng"&gt;&lt;/ion-input&gt;
      &lt;/ion-item&gt;
  
      &lt;ion-item&gt;
        &lt;ion-input type="text" name="message" placeholder="message" [(ngModel)]="data.message"&gt;&lt;/ion-input&gt;
      &lt;/ion-item&gt;
  
      &lt;ion-item&gt;
        &lt;ion-input type="text" name="username" placeholder="Username" [(ngModel)]="data.username"&gt;&lt;/ion-input&gt;
      &lt;/ion-item&gt;
  
      &lt;button (click)="getLocation()" class="button button-full button-calm"&gt;Get Location&lt;/button&gt;
  
      &lt;button block (click)="submit()"&gt;Submit to server&lt;/button&gt;
  
    &lt;/ion-list&gt;
  
  &lt;/ion-content&gt; 
  </code></pre>
  
  <p>js</p>
  
  <pre><code>import {Page} from 'ionic/ionic';
  import {Inject} from 'angular2/core';
  import {Http} from 'angular2/http';
  import 'rxjs/add/operator/map';
  
  @Page({
    templateUrl: 'build/pages/formstuff/formstuff.html',
  })
  export class FormstuffPage {
    constructor(@Inject(Http) http: Http) {
      this.data = {};
      this.data.message = '';
      this.data.lat = '';
      this.data.lng = '';
      this.data.response = '';
      this.http = http;
    }
  
    submit() {
        let link = 'http://api.php';
        let data = JSON.stringify({message: this.data.message, lat: this.data.lat, lng: this.data.lng});
        this.http.post(link, data)
        .subscribe(data =&gt; {
          this.data.response = data._body;
        }, error =&gt; {
            console.log("error");
        });
      }
  
    getLocation() {
      let options = {timeout: 2000, enableHighAccuracy: false};
      if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(geoLatlng, geoErrors, options);
      } else {
          console.log "conection error"
      }
    }
  
    function geoLatlng(position) {
        let latitude = position.coords.latitude;
        let longitude = position.coords.longitude;
        console.log ('cordinates'latitude,longitude);
    }
  
    function geoErrors(error) {
    }
  }
  </code></pre>