Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Set input value = '' before a server request

$
0
0

@JulioNicolasPapp wrote:

Hello, I’m new in Ionic, and need to put a value of an input with empty with typescript. Can i do this? How?

<ion-content padding>
  <ion-list>
  <ion-item>
  <ion-label floating>Username</ion-label>
  <ion-input type="text" name="username" [(ngModel)]="data.username"></ion-input>
  </ion-item>
  <button ion-button block (click)="submit()">Submit to server</button>
  </ion-list>
submit() {
 var link = 'http://jundar.ironhide.com.ar/web.php';
 var myData = JSON.stringify({username: this.data.username});

 this.http.post(link, myData)
 .subscribe(data => {
 this.data.response = data["_body"];

 //https://stackoverflow.com/questions/39574305/property-body-does-not-exist-on-type-response
 }, error => {
 console.log("Oooops!");
 });
 }

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles