You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-3
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,30 @@
2
2
3
3
This directive validates monetary inputs in "42.53" format (some additional work is needed for "32,00" Europoean formats). Note that this is _not_ designed to work with currency symbols. It largely behaves like Angular's implementation of `type="number"`.
4
4
5
-
It does just a few things:
5
+
It does a few things:
6
6
7
7
- Prevents entering non-numeric characters
8
8
- Prevents entering the minus sign when `min >= 0`
9
+
- Supports `min` and `max` like in `<input type="number">`
10
+
- Rounds the model value by `precision`, e.g. `42.219` will be rounded to `42.22` by default
9
11
- On `blur`, the input field is auto-formatted. Say if you enter `42`, it will be formatted to `42.00`
10
12
11
13
12
14
## Usage:
15
+
16
+
### Attributes:
17
+
-`money`: _required_
18
+
-`ng-model`: _required_
19
+
-`type`: Set to `text` or just leave it out. Do _not_ set to `number`.
20
+
-`min`: _optional_ Defaults to `0`.
21
+
-`max`: _optional_ Not enforced by default
22
+
-`precision`: _optional_ Defaults to `2`. Set to `-1` to disable rounding
23
+
13
24
```html
14
-
<inputtype="text"moneymin="1"max="100">
25
+
<inputtype="text"ng-model="model.price"money>
15
26
```
16
27
17
-
`min` defaults to `0`; set `min=-Infinity` to allow negative values.
28
+
## Tests:
29
+
30
+
1. Install test deps: `npm install` and `bower install`
0 commit comments