Fill input field with text


I’m wondering, how it is possible to fill input field with text, in my case retrieved data value from database, which want be into the input field after registration with logged in.

If I got some value from variable: public existName: string; and input field with placeholders. I can show it with placeholder placeholder="Name {{existName}}":

      <ion-input type="text" [(ngModel)]="name" placeholder="Name {{existName}}" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Name'"></ion-input>

but how to add it inside the input field, for example with page load or event, as editable text, allow user to see exist data in input fields. With using of value={{existName}}:

      <ion-input value={{existName}} type="text" [(ngModel)]="name" placeholder="Name" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Name'"></ion-input>

I got error:

Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: ‘model: null’. Current value: ‘model: aghata’.

Looking from your code, it seems like your ion-input value is tied to the name variable since you used _[(ngModel)]=“name” Updating the name variable should update the value in your input as well

1 Like

@jchoh0522 Hello,

Sorry for late answer

Yes [(ngModel)]="existName" thanks