7

<input class="form-control" [(ngModel)]="valami.Price">

Hi! Is there any simple way to format a number in this case?

now it displays 1000 for example. the goal is to display 1 000.00 i know pipes are not allowed in ngModel so

{{valami.Price | number: 3.2-2}}

is not working here.

the second question is how to replace the thousand separator? the default is ',' what i want to change to ' '. should i write a transform function in the component or, is there any simple way to do that?

thanks

toxikus
  • 71
  • 1
  • 2
  • 2
    I think you should be able to use pipes with ngModel like this: `[ngModel]="valami.Price | number: '3.2-2'" (ngModelChange)="updatePrice($event)"` – Riscie Feb 01 '17 at 07:46
  • 1
    thanks. i modified it to [ngModel]="valamiPrice | number: '1.2-2'" (ngModelChange)="valami.Price = $event" and now its working like two-way binding – toxikus Feb 01 '17 at 12:19
  • But do you want to format it the way you stated inside the form? That could be a problem because then it's not a number anymore... – Riscie Feb 01 '17 at 12:39

0 Answers0