Reputation: 111
I know this is similar or duplicate to this , I want to use pipe on ngmodel like this [ngModel]="item.value | currency:'USD$'"
but i have a scenario where I need to bind a method like this (ngModelChange)="someMethod()"
instead of setting the value (ngModelChange)="item.value=$event"
. How to achieve both of them together.
My Code:
<input type="text" [(ngModel)]="item.value | currency:'USD$'" (ngModelChange)="someMethod()" />
Upvotes: 0
Views: 4502
Reputation: 817
Drop the parenthesis like so, and pass the event to your method.
<input type="text" [(ngModel)]="item.value | currency:'USD$'" (ngModelChange)="someMethod()" />
Then in your .ts file you can assign the value:
someMethod(event) {
item.value = event;
//Other stuff you were doing before
}
Upvotes: 0
Reputation: 190
Try like this
<input type="text" [ngModel]="item.value | currency:'USD$'" (ngModelChange)="someMethod($event)" />
Upvotes: 1
Reputation: 13
Try removing square bracket from ngModel and see if that helps. It worked for me.
Upvotes: 0