I am receiving a value, that I display to the user in a text field.
The idea is for him to be able to edit this value, and then send it back.
In the case of money, let's say I store the amount in cents, but I want to display it in dollars. Here is an idea of the code I have that display the value I receive :
<input type="text" [(ngModel)]="myValue" value="{{myValue}}" />
I tried this without success :
<input type="text" [(ngModel)]="myValue/100" value="{{myValue/100}}" />
How can I display that value divided by 100 ?
Use the desugared syntax of [()]
.
<input type=text [(ngModel)]="myValue">
is equivalent to
<input type=text [ngModel]="myValue" (ngModelChange)="myValue = $event">
This means that you can separately control how do you want data to flow in, and how should events flow out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With