Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 34e5d42

Browse files
committed
Update readme.
1 parent 7076c15 commit 34e5d42

File tree

1 file changed

+35
-25
lines changed

1 file changed

+35
-25
lines changed

README.md

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,26 @@ This is an Angular.js filter that applies [Numeral.js](http://numeraljs.com/) fo
88

99
2. Include either the minified or non-minified javascript file from the `/dist/` folder:
1010

11-
```html
11+
```html
1212
<script src="angular-numeraljs.js"></script>
13-
```
13+
```
1414

1515
3. Inject the `ngNumeraljs` filter into your app module:
1616

17-
```javascript
18-
var myApp = angular.module('myApp', ['ngNumeraljs']);
19-
```
20-
21-
4. Apply the filter:
17+
```javascript
18+
var myApp = angular.module('myApp', ['ngNumeraljs']);
19+
```
2220

23-
```html
21+
4. Apply the filter with the desired format string:
22+
```html
2423
<p>
2524
{{ price | numeraljs:'$0,0.00' }}
2625
</p>
27-
```
26+
```
2827

2928
## Advanced Usage
3029

31-
You can configure `ngNumberaljs` before actual usage with few options available.
30+
You can configure `ngNumeraljs` during Angular's configuration phase using the $numeraljsConfigProvider:
3231

3332
```js
3433
var app = angular.module('exampleApp', ['ngNumeraljs']);
@@ -38,9 +37,11 @@ app.config(['$numeraljsConfigProvider', function ($numeraljsConfigProvider) {
3837
}]);
3938
```
4039

41-
### Set formatters
40+
Numeral.js must be already loaded in the browser prior to using `$numeraljsConfigProvider`.
4241

43-
`$numeraljsConfigProvider.setFormat(name, formatString)` - allows to define a named format, that can be used during formatting.
42+
### Named Formats
43+
44+
`$numeraljsConfigProvider.setFormat(name, formatString)` - defines a named format which can be used in place of the format string in the filter.
4445

4546
```js
4647
app.config(['$numeraljsConfigProvider', function ($numeraljsConfigProvider) {
@@ -51,14 +52,16 @@ app.config(['$numeraljsConfigProvider', function ($numeraljsConfigProvider) {
5152
In markup,
5253

5354
```html
54-
<p>
55-
{{ price | numeraljs:'currency' }}
56-
</p>
55+
<p>
56+
{{ price | numeraljs:'currency' }}
57+
</p>
5758
```
5859

59-
### Set default format
60+
### Default Format
61+
62+
Numeral.js defines the default format as '0,0', so this format is used if none is provided to the filter.
6063

61-
`$numeraljsConfigProvider.setDefaultFormat(format)` - allows to define default format, one that is used if format is not specified.
64+
`$numeraljsConfigProvider.setDefaultFormat(format)` - overrides the built-in default format.
6265

6366
```js
6467
app.config(['$numeraljsConfigProvider', function ($numeraljsConfigProvider) {
@@ -69,14 +72,14 @@ app.config(['$numeraljsConfigProvider', function ($numeraljsConfigProvider) {
6972
In markup,
7073

7174
```html
72-
<p>
73-
{{ price | numeraljs }} <!-- will produce 15.5 $ -->
74-
</p>
75+
<p>
76+
{{ price | numeraljs }} <!-- will produce 15.5 $ -->
77+
</p>
7578
```
7679

77-
### Set language definition
80+
### Custom Languages
7881

79-
`$numeraljsConfigProvider.setLanguage(langId, definition)` - allows to add language definition. Check out already available [languages](https://github.com/adamwdraper/Numeral-js/tree/master/languages).
82+
`$numeraljsConfigProvider.setLanguage(langId, definition)` - adds new language definitions to Numeral.js. See the available list here: [languages](https://github.com/adamwdraper/Numeral-js/tree/master/languages).
8083

8184
```js
8285
app.config(['$numeraljsConfigProvider', function ($numeraljsConfigProvider) {
@@ -103,9 +106,11 @@ app.config(['$numeraljsConfigProvider', function ($numeraljsConfigProvider) {
103106
}]);
104107
```
105108

106-
### Set current language
109+
Languages can be loaded directly into Numeral.js as well, e.g. by loading the [language files](https://github.com/adamwdraper/Numeral-js/tree/master/languages) after Numeral.js is loaded. Angular-numeraljs can use these languages even if they are not set via this provider.
107110

108-
`$numeraljsConfigProvider.setCurrentLanguage(langId)` - allows to set currently used language.
111+
### Select Language
112+
113+
`$numeraljsConfigProvider.setCurrentLanguage(langId)` - selects the current language. The language must be loaded either by `$numeraljsConfigProvider.setLanguage()` or by loading the Numeral.js language file.
109114

110115
```js
111116
app.config(['$numeraljsConfigProvider', function ($numeraljsConfigProvider) {
@@ -137,4 +142,9 @@ This filter can be installed via Bower with the following dependency in the `bow
137142

138143
grunt build
139144

140-
The `/dist/' folder contains the regular and minified Javascript files.
145+
The `/dist/` folder contains the regular and minified Javascript files.
146+
147+
4. Tests are automatically run during the build, but they can be run manually as well
148+
149+
grunt test
150+

0 commit comments

Comments
 (0)