Is it possible for a user to edit their data? I have made the data accessible on this page, stored in information
. I would like the user to see their data upon entering the view, such as their username or email, and be able to edit or delete it. I initially attempted using placeholders, but they are not the actual input. I also tried initializing the data in my form, but that did not work either.
This is what I have attempted:
page.html
...
<ion-item class="input-item">
<ion-label color="secondary" position="floating">Username</ion-label>
<ion-input type="text" formControlName="username" required></ion-input>
</ion-item>
...
page.ts
ngOnInit() {
if (this.authService.authenticationState) {
this.storage.get(USER_ID).then(val => {
this.id = val;
console.log(this.id);
this.userService.getUserDetails(this.id).subscribe(result => {
this.information = result;
console.log(this.information);
});
});
}
this.updateUserForm = new FormGroup({
username: new FormControl('', Validators.required),
email: new FormControl('', Validators.compose([
Validators.required,
Validators.pattern('^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$')
])),
birthdate: new FormControl(Validators.required),
gender: new FormControl(this.genders[0], Validators.required),
});
}