I have two pages and I want the value of an event (script below) from Page 2 to be displayed in an input on Page 1.
Page 1 HTML:
<ion-list>
<ion-item text-center>
<ion-input type="text" [(ngModel)]="forca"></ion-input>
<ion-label stacked>Força</ion-label>
</ion-item>
</ion-list>
HTML Page 2:
<ion-list>
<ion-item-sliding #item>
<ion-item (click)="showConfirm()">
<ion-avatar item-left>
<img src="assets/img/adagas.png">
</ion-avatar>
<h2>Adagas Sangrentas</h2>
<h3>Força +1, Agilidade +1</h3>
<p>Adagas preparadas para derramar sangue, feitas com lâminas forjadas em aço raro e fino.</p>
</ion-item>
<ion-item-options side="left">
<button
[style.backgroundColor]= "ativo ? 'green' : 'red'"
(click)="usar()"
>Usar</button>
</ion-item-options>
</ion-item-sliding>
</ion-list>
Page 2 script:
usar() {
this.ativo = !this.ativo;
this.forca = 1;
console.log(this.forca);
}
In this case, by clicking on "Use" the value of the "force" input change to 1.