Reputation: 147
I have the below code written , on the paste event I want to change the ngModel value
<input [ngModel]="field[index].value" (paste)="field[index].value=myFunction($event)"/>
myFunction in component is as below:
myFunction(event):string
{
//Some String processing
return "pasted_processed_Value";
}
However, I am able to log the processed string in myFunction method but the value returned from myFunction is not updated in ngModel
Upvotes: 0
Views: 1639
Reputation: 3451
Make it a two-way binding instead -> [(ngModel)]
<input [(ngModel)]="field[index].value" (paste)="field[index].value=myFunction($event)"/>
Upvotes: 0
Reputation: 1164
<input [ngModel]="hello" (paste)="myFunction($event)"/>
myFunction(event):string
{
//Some String processing
this.hello = "pasted_processed_Value";
}
EDIT:
(paste)="myFunction($event, field[index])"
myFunction(event, field):string
{
//Some String processing
field.value = "pasted_processed_Value";
}
Upvotes: 1