ng2-mask-money
ng2-mask-money copied to clipboard
Directive for money input mask in angular 7
DEPRECATED 
ng2-money-mask Directive
A very simple currency mask directive for Angular. You should use the version 7.x.x for Angular 7.x.x.
Note: This component is NOT ready to AoC (Ahead-of-Time) compilation.
Getting Started
Installing and Importing
Install the package by command:
npm install ng2-money-mask --save
Import the module
import {MoneyMaskModule} from 'ng2-money-mask';
@NgModule({
declarations: [...],
imports: [
//... you others modules
MoneyMaskModule
],
providers: [...]
})
export class AppModule {}
Using
<input [(ngModel)]="moneyText" [(moneyModel)]="moneyValue" mask-money />
-
ngModel
will get/set the value with text (example:'$ 1,234.56'
) ; -
moneyModel
will get/set the number value (example:1234.56
);
Options
You can set options...
<!-- example for pt-BR money -->
<input [(ngModel)]="moneyText" [(moneyModel)]="moneyValue" [money-mask-options]="{ prefix: 'R$ ', thousands: '.', decimal: ',' }" mask-money />
Available options:
-
allowNegative
- Iftrue
can input negative values. (default:false
) -
precision
- Number of decimal places (default:2
) -
thousands
- Separator of thousands (default:','
) -
decimal
- Separator of decimals (default:'.'
) -
prefix
- Money preffix (is included in ngModel) (default:'$ '
) -
suffix
- Money suffix (is included in ngModel) (default:''
)