I am doing CRUD operations with multiple fields. I have [(ngModel)] for all fields.
I am not interested in changing the name [(ngModel)] or assigning any value in the register.ts or edituser.ts at boot time. Since I made a form to save the values ββsuccessfully in the registration mode in the database. I need to show the Inserted value in the Edit User Form and how I can accomplish this.
Note. I have several other fields: a text field, a text field, a password in both forms, but somehow I managed to save the data in the database during the registration process and in the "Edit user" section, also I have displayed the values ββthat were added in edit mode for all other input types except ion-select .
For example: In the registration form, if the user selected βMaleβ as an option in the editing mode, I need to stay with the user input right, but βSexβ is displayed again in the form instead of showing the selected value.
Below I have listed both forms containing ion-select , and my efforts that I have made.
register.html
<ion-item> <ion-label floating>Gender</ion-label> <ion-select [(ngModel)]="gender"> <ion-option value="Male">Male</ion-option> <ion-option value="Female">Female</ion-option> </ion-select> </ion-item>
Edituser.html
I tried different options, but only one. But this is not the one I'm looking for. At the moment, [(ngModel)]="editUser.gender" works, and the value is selected in the parameter tag, but I do not need this. I need a model as follows [(ngModel)]="gender" , but the value must be selected using any of the available methods.
<ion-item> <ion-label floating>Gender</ion-label> <ion-select [(ngModel)]="editUser.gender" name="gender"> <ion-option value="Male">Male</ion-option> <ion-option value="Female">Female</ion-option> </ion-select> </ion-item>
editUser contains JSON data that comes from the database.
The main drawback here is that when I provide such a model name, this value is not retrieved when the form is submitted. Therefore, I need the value to be selected without changing in [(ngModel)] .
My goal is to save the model as I am in the form register.html [(ngModel)] = "gender" for both the Registration and the Edit Form.
javascript ionic-framework angular2-directives hybrid-mobile-app ionic3
Naresh Kumar .P
source share