Reputation: 753
I am trying to do two-way data binding using a function. Below is my code.
<input type="text" id="txtCurrentPrice" class="traderviewTxtBox" [(value)]="numberFormat(23236448)">
my function is
numberFormat(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
I am getting the below error. Can anybody help.
Unhandled Promise rejection: Template parse errors:
Parser Error: Unexpected token '=' at column 23 in [numberFormat(23236448)=$event] in myComponent@241:101 ("<input type="text" id="txtCurrentPrice" class="traderviewTxtBox" [ERROR ->][(value)]="numberFormat(23236448)">
<!--<dx-text-box id="txtCurrentP"): myComponent@241:101
Upvotes: 0
Views: 526
Reputation: 38353
Two-way databinding doesn't seem to be possible to a function as the function is a output operation.
You can bind to the value property one-way using the function by removing the parentheses:
<input type="text" id="txtCurrentPrice" class="traderviewTxtBox" [value]="numberFormat(23236448)">
Upvotes: 0