Pass value to another page from a label


#1

Hello everyone!

I’m currently trying to pass a value in a label to another page so I can make an calculation using this variable, can someone help me with that? I’m currently passing a value to another page but from an input…

This is the code from source page:

ControlarGlicemia.html


h4 style="color:rgb(49, 96, 250);" align="center">Total de Carboidratos</h4>

<h3 style="color:grey;" align="center">{{carboidratos}}</h3>

<br>

<br>

<button navPush="InsulinaPage" ion-button full (click)="goTo(glicemiaAtual.value)">Calcular</button>

<button navPush="MenuPage" ion-button block clear round full>Voltar</button>

I want to pass the value {{carboidratos}} to another page using the button in the end of the code.

How can I do that?

Thanks!


#2
(click)="goTo(glicemiaAtual.value, carboidratos)"

#3
clickMethod() {
  this.nav.push(ComponentName, {"carboidratos":this. carboidratos});
}

#4

Hi @lizavlin. If your able to render a variable in the template means, you have it’s value in the .ts file. So just use it on click of a button.

this.navCtrl.push(ComponentName, {"carboidratos":this. carboidratos});

Where navCtrl is a instance of NaviagationController