P Rane
P Rane

Reputation: 306

How to use ng2-currency-mask in angular 6 Project

I'am using ng2-currency-mask module in my Angular 6 project but when apply (change) method in input fields its not working

here i used input tag

                        <input style="text-align:right; width:260px;" currencyMask  [options]="{ prefix: 'Rs ', thousands: ',', decimal: '.' }" (change)="addToAllChange($event.target.value)" placeholder="Value" class="form-control"/>

Upvotes: 2

Views: 8215

Answers (1)

Sunil
Sunil

Reputation: 11243

You are not able to trigger change even because of currencyMask directive. You can leverage ngModel and ngModelChange.

<input style="text-align:right; width:260px;" currencyMask  
  [options]="{ prefix: 'Rs ', thousands: ',', decimal: '.' }" 
  #currency
  (ngModelChange)="addToAllChange(currency.value)" 
  [(ngModel)]="value"
  placeholder="Value" 
  class="form-control"/>

If you want to control on when it should be updated, you can use ngModelOption.

Upvotes: 5

Related Questions