Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229599

Ionic 2 Form with ngModel

$
0
0

try this

import { FormGroup, FormBuilder, Validators } from '@angular/forms';
export class testClass {
testForm: FormGroup;
constructor(private fb: FormBuilder) {
	this.testForm = this.fb.group({
		fullname: ['', Validators.required],
		email: ['', Validators.email]
	})
}
editProfile(): void {
	this.loadingprovider.showupdate(this); 
      this.profileService.upload(this.testForm.value)
      .subscribe(data =>{
        this.loading.dismiss();
        this.navCtrl.setRoot(ProfilePage);
      },(err)=>{
        this.loading.dismiss();
      })
}

}

<form [formGroup]="testForm" (ngSubmit)="editprofile()" >
  <ion-list >
    <ion-item>
      <ion-label stacked>{{'Fullname' | translate}}</ion-label>
      <ion-input type="text"  formControlName="fullname" name = "fullname" ></ion-input>
    </ion-item>
    <ion-item>
      <ion-label stacked>{{'Email' | translate}}</ion-label>
      <ion-input type="text" formControlName="email"name = "email"></ion-input>
    </ion-item>
  </ion-list>
  <button ion-button block (click)="editprofile()">{{'Update' | translate}}</button>

Viewing all articles
Browse latest Browse all 229599

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>