Code HTML
<div *ngFor='let user of arrayUser'>
<form (ngSubmit)="UpdateMe()" >
<ion-item>
<ion-label>Nom</ion-label>
<ion-input type="text" [(ngModel)]="user.nom" name='nom' ></ion-input>
</ion-item>
<ion-item>
<ion-label>Prenom</ion-label>
<ion-input [(ngModel)]="user.prenom" name="prenom"></ion-input>
</ion-item>
<ion-button ion-button type="submit" color='secondary' expand="full" block >Update</ion-button>
</form>
</div>
Code ts
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Storage } from '@ionic/storage';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'app-update-user',
templateUrl: './update-user.page.html',
styleUrls: ['./update-user.page.scss'],
})
export class UpdateUserPage implements OnInit {
constructor(
private Http: HttpClient,
private storage: Storage,
) { }
apiUrl='xxxxxxxxxxxxxxxx/mobile/myName.php';
arrayUser:any;
nom:string='';
user={};
ngOnInit() {
this.storage.get('id').then((val) => {
this.Http.post(this.apiUrl,JSON.stringify(val)).subscribe(data=>{
this.arrayUser=data;
});
});
}
UpdateMe(){
console.log(user);
}
}
console.log(user) get data empty