@@ -4,14 +4,87 @@ AngularJS factory that parse Link header and return a JSON object.
44
55## TODO
66
7+ * unit testing
8+ * more code documentations
9+ * add examples
10+
711## License
812
9- Released under the terms of the [ MIT License] ( ) .
13+ Released under the terms of the [ MIT License] ( https://github.com/igorissen/angular-link-header-parser/blob/master/LICENSE.md ) .
1014
1115## Contributing
1216
17+ If you want to contribute, please read this small [ guide] ( https://github.com/igorissen/angular-link-header-parser/blob/master/CONTRIBUTING.md ) .
18+
1319## Changelog
1420
21+ You ask yourself what has changed? Please read the [ changelog] ( https://github.com/igorissen/angular-link-header-parser/blob/master/CHANGELOG.md ) .
22+
1523## Installation
1624
17- ## Usage
25+ ```
26+ bower install [--save] angular-link-header-parser
27+ ```
28+
29+ ## Usage
30+
31+ Include ` angular-link-header-parser.js ` or minified version ` angular-link-header-parser.min.js ` .
32+
33+ ``` html
34+ <script src =" path/to/vendors/angular-link-header-parser/release/angular-link-header-parser.js" ></script >
35+ <!-- OR -->
36+ <script src =" path/to/vendors/angular-link-header-parser/release/angular-link-header-parser.min.js" ></script >
37+ ```
38+
39+ Add the module ` ig.linkHeaderParser ` as a dependency to your app module.
40+
41+ ``` js
42+ angular .module (" app" , [ " ig.linkHeaderParser" ]);
43+ ```
44+
45+ Then when needed inject ` linkHeaderParser ` as a dependency.
46+
47+ ``` js
48+ angular
49+ .module (" app" )
50+ .controller (" Controller" , Controller);
51+
52+ Controller .$inject = [ " linkHeaderParser" ];
53+
54+ function Controller (linkHeaderParser ) {
55+ var vm = this ;
56+
57+ var linkHeaderText = ' <http://localhost:28786/dev/certifications?page=1&limit=100>; rel="first", <http://localhost:28786/dev/certifications?page=1&limit=100>; rel="last", <http://localhost:28786/dev/certifications?page=1&limit=100>; rel="next", <http://localhost:28786/dev/certifications?page=1&limit=100>; rel="prev"' ;
58+
59+ var json = linkHeaderParser .parse (linkHeaderText);
60+
61+ console .log (json);
62+ }
63+ ```
64+
65+ You will receive a JSON object like this :
66+
67+ ``` json
68+ {
69+ "first" : {
70+ "limit" : 100 ,
71+ "page" : 1 ,
72+ "url" : " http://localhost:28786/dev/certifications?page=1&limit=100"
73+ },
74+ "last" : {
75+ "limit" : 100 ,
76+ "page" : 1 ,
77+ "url" : " http://localhost:28786/dev/certifications?page=1&limit=100"
78+ },
79+ "next" : {
80+ "limit" : 100 ,
81+ "page" : 1 ,
82+ "url" : " http://localhost:28786/dev/certifications?page=1&limit=100"
83+ },
84+ "prev" : {
85+ "limit" : 100 ,
86+ "page" : 1 ,
87+ "url" : " http://localhost:28786/dev/certifications?page=1&limit=100"
88+ },
89+ }
90+ ```
0 commit comments