Save value to a variable

Asked

Viewed 483 times

1

How can I save the value of a calculation done in front-end by passing to a variable in typescript, example:

Typescript:

valor:number=0;

html:

<ion-input type="number" [(ngModel)]="valor"></ion-input>
<p>{{valor * valor}}</p>

In typescript is stored only the value that was typed in the input, what needs is to put in a variable the calculation made by the paragraph: <p>{{valor * valor}}</p>

I tried the following logic without success:

Typescript:

this.result = this.valor * this.valor;

html:<p>{{result}}</p>

  • What happens in your example? Does Undefined? Or do you have an error in the console? Press F12 to see if there are any errors to post here.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.