Ion-input does not display the changed value

In .html file

<ion-input name=“address” type=“text” [(ngModel)]=“address”>

<button ion-button full (click)=“changeMe()” >

in .ts file
changeMe(){
this.address=“abc”;
}

when the button is clicked then it shows no update to input field .
only when i click on input field after clicking on button then only input is filled.
what i should do to auto populate the input area when the button is clicked.
I am new to ionic , any help guys.

Did you forgot to add adress into your properties ?

adress: any;

i have added that already ,
but it didn’t work after that also.

If you add this address = 'abc'; does it display anything ?

Oh I have spotted your problem!

Just create a div with something like this.

<div>{{address}}</div>


TS:

address: any;

changeMe(){
this.address=“abc”;
}

HTML:

<ion-input name=“address” type=“text” [(ngModel)]=“address”></ion-input>
<div>{{address}}</div>
<button ion-button full (click)=“changeMe()”></button>

Now you should be able to see your value.

i have added <div>{{address}}</div> but even after that it does not display anything after clicking on the button .
Only when i click on the address field then it displays the abc text in that.

Alright i fixed it. Forget the ngModel, you don’t need it for this.

TS:

address: any;


    changeMe() {
      this.address = 'abc';
    }

HTML:

<div>{{address}}</div>
<button ion-button full (click)=“changeMe()”></button>

This should work 100% just tested it out myself :bird:

but i want the input field to be auto filled with abc.

Then you only have to set address = 'abc'; then it will be setted by default.

no it did’t work on the code i posted.

Then you are doing something wrong because it works 100% on my testapp.

Care to post your whole code ? :slight_smile:

finally got the answer to problem.
used NgZone to auto-populate address field on click.
thanks anyway @cherry for helping.