Two way data binding in separated

Does someone know why this code doesn’t work? And what would be the correct way to do that?

<ion-input type="number" (ngModel)="table.price" [ngModel]="table.price.toFixed(2)"></ion-input>

The table.price is inserted into ion-input after load, but if I change the value, the table.price doesn’t receive the ion-input typed.


The convention is (ngModelChange) in this situation, not (ngModel).

Sorry, it didn’t solve.

Leaving aside the fact that you should never be putting function calls in [ngModel] (because change detection can’t tell they’re stable), the following does what I would expect in a scratch project:

   <ion-input [ngModel]="fruit" (ngModelChange)="onFruitChange($event)"></ion-input>
  onFruitChange(fruit: string) {
    console.log("fruit changed " + fruit);