0

I am relatively new to the IONIC app development. Now i am face a problem that,i need to send multiple input field which generate dynamically from the MySQL PHP. ie, i have a input field which i can be updated and send to the server that is my requirement.

Now i am able to get data from my server and generate the input field.but iam unable to send the (updated if any) to the server back by clicking a button

   <ion-list>
  <ion-item no-margin="">
  <ion-grid>
    <strong><ion-row>
      <ion-col>Student code</ion-col>
      <ion-col>name</ion-col>
      <ion-col>phone</ion-col>
    </ion-row>
    </strong>
  </ion-grid>
  </ion-item>
  <ion-grid>
    <ion-row *ngFor="let student of students">
      <ion-col >{{student.student_code}}</ion-col>
      <ion-col>{{student.full_name}}</ion-col>
      <ion-col ion-item=""><ion-input  maxlength="10" required [(ngModel)]="student.phone"></ion-input></ion-col>
    </ion-row>
  </ion-grid>
</ion-list>

here is the .ts file

    loadStudents(division){
this.rest.loadStudents(division)
.subscribe(data=>{
this.students=data;

  },error1 => {
    console.log(error1);
  });

}

here is the html template which dynamically loaded

1 Answer 1

2

You will get updated data in this.students array itself :

Just save the data on button click :

HTML :

<button (click)="UpdateStudents()"> Save Updated Data </button>

TS :

UpdateStudents(){
  this.rest.UpdateStudents(this.students)
  .subscribe(response=>{
       console.log(response);
  },error => {
       console.log(error);
 });
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.