This package has been deprecated

Author message:

Package not maintained! Please use another package

angular-link-header-parser

1.0.3 • Public • Published

angular-link-header-parser

AngularJS factory that parse Link header and return a JSON object.

TODO

  • unit testing
  • more code documentations
  • add examples

License

Released under the terms of the MIT License.

Contributing

If you want to contribute, please read this small guide.

Changelog

You ask yourself what has changed? Please read the changelog.

Installation

bower install [--save] angular-link-header-parser

Usage

Include angular-link-header-parser.js or minified version angular-link-header-parser.min.js.

<script src="path/to/vendors/angular-link-header-parser/release/angular-link-header-parser.js"></script>
<!-- OR -->
<script src="path/to/vendors/angular-link-header-parser/release/angular-link-header-parser.min.js"></script>

Add the module ig.linkHeaderParser as a dependency to your app module.

angular.module("app", [ "ig.linkHeaderParser" ]);

Then when needed inject linkHeaderParser as a dependency.

angular
  .module("app")
  .controller("Controller", Controller);

Controller.$inject = [ "linkHeaderParser" ];

function Controller(linkHeaderParser) {
  var vm = this;
  
  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"';
  
  var json = linkHeaderParser.parse(linkHeaderText);
  
  console.log(json);
}

You will receive a JSON object like this :

{
  "first": {
    "limit": 100,
    "page": 1,
    "url": "http://localhost:28786/dev/certifications?page=1&limit=100"
  },
  "last": {
    "limit": 100,
    "page": 1,
    "url": "http://localhost:28786/dev/certifications?page=1&limit=100"
  },
  "next": {
    "limit": 100,
    "page": 1,
    "url": "http://localhost:28786/dev/certifications?page=1&limit=100"
  },
  "prev": {
    "limit": 100,
    "page": 1,
    "url": "http://localhost:28786/dev/certifications?page=1&limit=100"
  },
}

Readme

Keywords

none

Package Sidebar

Install

npm i angular-link-header-parser

Weekly Downloads

34

Version

1.0.3

License

MIT

Unpacked Size

14.2 kB

Total Files

11

Last publish

Collaborators

  • igorissen