ngx-currency
Advanced tools
Comparing version 1.1.0 to 1.1.1
/** | ||
* ngx-currency - A very simple currency mask directive that allows using a number attribute with the ngModel. | ||
* @version v1.1.0 | ||
* @version v1.1.1 | ||
* @author Neri Bez Fontana | ||
@@ -5,0 +5,0 @@ * @link https://github.com/nbfontana/ngx-currency#readme |
/** | ||
* ngx-currency - A very simple currency mask directive that allows using a number attribute with the ngModel. | ||
* @version v1.1.0 | ||
* @version v1.1.1 | ||
* @author Neri Bez Fontana | ||
@@ -5,0 +5,0 @@ * @link https://github.com/nbfontana/ngx-currency#readme |
@@ -5,2 +5,18 @@ # Change Log | ||
<a name="1.1.1"></a> | ||
## [1.1.1](https://github.com/nbfontana/ngx-currency/compare/v1.1.0...v1.1.1) (2017-09-29) | ||
### Bug Fixes | ||
* unused import ([9bdd946](https://github.com/nbfontana/ngx-currency/commit/9bdd946)) | ||
### Features | ||
* gh-pages branch up ([b1210af](https://github.com/nbfontana/ngx-currency/commit/b1210af)) | ||
* travis.yml ([90517f6](https://github.com/nbfontana/ngx-currency/commit/90517f6)) | ||
<a name="1.1.0"></a> | ||
@@ -7,0 +23,0 @@ # 1.1.0 (2017-09-29) |
{ | ||
"name": "ngx-currency", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A very simple currency mask directive that allows using a number attribute with the ngModel.", | ||
@@ -5,0 +5,0 @@ "main": "./bundles/ngx-currency.umd.js", |
155
README.md
# ngx-currency | ||
ngx-currency | ||
[](https://travis-ci.org/nbfontana/ngx-currency) | ||
[](http://badge.fury.io/js/ngx-currency) | ||
[](https://david-dm.org/nbfontana/ngx-currency?type=dev) | ||
[](https://github.com/nbfontana/ngx-currency/issues) | ||
[](https://github.com/nbfontana/ngx-currency/stargazers) | ||
[](https://raw.githubusercontent.com/nbfontana/ngx-currency/master/LICENSE) | ||
## Demo | ||
https://nbfontana.github.io/ngx-currency/ | ||
## Table of contents | ||
- [About](#about) | ||
- [Installation](#installation) | ||
- [Documentation](https://nbfontana.github.io/ngx-currency/docs/) | ||
- [Development](#development) | ||
- [License](#license) | ||
## About | ||
## Getting Started | ||
### Installing and Importing | ||
Install the package by command: | ||
```sh | ||
npm install ngx-currency --save-dev | ||
``` | ||
Import the module | ||
```ts | ||
import { NgxCurrencyModule } from "ngx-currency"; | ||
@NgModule({ | ||
imports: [ | ||
... | ||
NgxCurrencyModule | ||
], | ||
declarations: [...], | ||
providers: [...] | ||
}) | ||
export class AppModule {} | ||
``` | ||
### Using | ||
```html | ||
<input currencyMask [(ngModel)]="value" /> | ||
``` | ||
* `ngModel` An attribute of type number. If is displayed `'$ 25.63'`, the attribute will be `'25.63'`. | ||
### Options | ||
You can set options... | ||
```html | ||
<!-- example for pt-BR money --> | ||
<input currencyMask [(ngModel)]="value" [options]="{ prefix: 'R$ ', thousands: '.', decimal: ',' }"/> | ||
``` | ||
Available options: | ||
* `align` - Text alignment in input. (default: `right`) | ||
* `allowNegative` - If `true` can input negative values. (default: `true`) | ||
* `decimal` - Separator of decimals (default: `'.'`) | ||
* `precision` - Number of decimal places (default: `2`) | ||
* `prefix` - Money prefix (default: `'$ '`) | ||
* `suffix` - Money suffix (default: `''`) | ||
* `thousands` - Separator of thousands (default: `','`) | ||
You can also set options globally... | ||
```ts | ||
import { NgxCurrencyModule } from "ngx-currency"; | ||
import { CurrencyMaskConfig, CURRENCY_MASK_CONFIG } from "ngx-currency/src/currency-mask.config"; | ||
export const CustomCurrencyMaskConfig: CurrencyMaskConfig = { | ||
align: "right", | ||
allowNegative: true, | ||
allowZero: true, | ||
decimal: ",", | ||
precision: 2, | ||
prefix: "R$ ", | ||
suffix: "", | ||
thousands: "." | ||
}; | ||
@NgModule({ | ||
imports: [ | ||
... | ||
NgxCurrencyModule | ||
], | ||
declarations: [...], | ||
providers: [ | ||
{ provide: CURRENCY_MASK_CONFIG, useValue: CustomCurrencyMaskConfig } | ||
], | ||
bootstrap: [AppComponent] | ||
}) | ||
export class AppModule {} | ||
``` | ||
## Quick fixes | ||
### Ionic 2-3 | ||
Input not working on mobile keyboard | ||
```html | ||
<!-- Change the type to 'tel' --> | ||
<input currencyMask type="tel" [(ngModel)]="value" /> | ||
``` | ||
Input focus get hide by the mobile keyboard | ||
on HTML | ||
```html | ||
<!-- Change the type to 'tel' --> | ||
<input currencyMask type="tel" [(ngModel)]="value" [id]="'yourInputId' + index" (focus)="scrollTo(index)" /> | ||
``` | ||
on .ts | ||
```ts | ||
import { Content } from 'ionic-angular'; | ||
export class... | ||
@ViewChild(Content) content: Content; | ||
scrollTo(index) { | ||
let yOffset = document.getElementById('yourInputId' + index).offsetTop; | ||
this.content.scrollTo(0, yOffset + 20); | ||
} | ||
``` | ||
## Development | ||
### Prepare your environment | ||
* Install [Node.js](http://nodejs.org/) and NPM | ||
* Install local dev dependencies: `npm install` while current directory is this repo | ||
### Development server | ||
Run `npm start` or `npm run demo` to start a development server on port 8000 with auto reload + tests. | ||
### Testing | ||
Run `npm test` to run tests once or `npm run test:watch` to continually run tests. | ||
## License | ||
MIT @ Neri Bez Fontana |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"InputHandler":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":9,"character":32,"context":{"typeName":"HTMLInputElement"}},{"__symbolic":"reference","name":"any"}]}],"handleCut":[{"__symbolic":"method"}],"handleInput":[{"__symbolic":"method"}],"handleKeydown":[{"__symbolic":"method"}],"handleKeypress":[{"__symbolic":"method"}],"handlePaste":[{"__symbolic":"method"}],"updateOptions":[{"__symbolic":"method"}],"getOnModelChange":[{"__symbolic":"method"}],"setOnModelChange":[{"__symbolic":"method"}],"getOnModelTouched":[{"__symbolic":"method"}],"setOnModelTouched":[{"__symbolic":"method"}],"setValue":[{"__symbolic":"method"}],"setCursorPosition":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"InputHandler":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":9,"character":32,"context":{"typeName":"HTMLInputElement"}},{"__symbolic":"reference","name":"any"}]}],"handleCut":[{"__symbolic":"method"}],"handleInput":[{"__symbolic":"method"}],"handleKeydown":[{"__symbolic":"method"}],"handleKeypress":[{"__symbolic":"method"}],"handlePaste":[{"__symbolic":"method"}],"updateOptions":[{"__symbolic":"method"}],"getOnModelChange":[{"__symbolic":"method"}],"setOnModelChange":[{"__symbolic":"method"}],"getOnModelTouched":[{"__symbolic":"method"}],"setOnModelTouched":[{"__symbolic":"method"}],"setValue":[{"__symbolic":"method"}],"setCursorPosition":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"InputHandler":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":8,"character":32,"context":{"typeName":"HTMLInputElement"}},{"__symbolic":"reference","name":"any"}]}],"handleCut":[{"__symbolic":"method"}],"handleInput":[{"__symbolic":"method"}],"handleKeydown":[{"__symbolic":"method"}],"handleKeypress":[{"__symbolic":"method"}],"handlePaste":[{"__symbolic":"method"}],"updateOptions":[{"__symbolic":"method"}],"getOnModelChange":[{"__symbolic":"method"}],"setOnModelChange":[{"__symbolic":"method"}],"getOnModelTouched":[{"__symbolic":"method"}],"setOnModelTouched":[{"__symbolic":"method"}],"setValue":[{"__symbolic":"method"}],"setCursorPosition":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"InputHandler":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":8,"character":32,"context":{"typeName":"HTMLInputElement"}},{"__symbolic":"reference","name":"any"}]}],"handleCut":[{"__symbolic":"method"}],"handleInput":[{"__symbolic":"method"}],"handleKeydown":[{"__symbolic":"method"}],"handleKeypress":[{"__symbolic":"method"}],"handlePaste":[{"__symbolic":"method"}],"updateOptions":[{"__symbolic":"method"}],"getOnModelChange":[{"__symbolic":"method"}],"setOnModelChange":[{"__symbolic":"method"}],"getOnModelTouched":[{"__symbolic":"method"}],"setOnModelTouched":[{"__symbolic":"method"}],"setValue":[{"__symbolic":"method"}],"setCursorPosition":[{"__symbolic":"method"}]}}}}] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
233619
156