qipp-services-paging
v1.2.0
Published
Paging service for Angular application.
Downloads
2
Readme
qipp-services-paging
General
This service provides a vertical pager that must be coupled with the qippPagingLoad directive. When called, it can get the next and previous endpoints thanks to the links property included in each API response.
Install
npm i qipp-services-paging
Angular usage
Directive qippPagingLoad implementation
Using a resource as $scope.resource:
<button qipp-paging-load="resource"
qipp-paging-cursor="next">
<span>Load more items</span>
</button>
The directive will call the load() method of the verticalPager provider.
In your controller
Load more items, as defined by the page size of the resource (this method is used internally by the corresponding directive). The second argument is the direction of the page (next/previous). A third argument can be provided to force replacement of the data in resource (i.e. not prepending nor appending it). A last argument can be set in order to add an emitter on the rootScope providing the enum properties of the resource:
$rootScope.$on('someEmitter', function (enum) {
// Do something.
})
verticalPager.load($scope.resource, 'next', false, 'someEmitter')
Use the verticalPager service for removing items:
$scope.removeThing = function (id, index) {
verticalPager.removeItem($scope.resource, id, index)
}
Three arguments must be provided: the resource, the id and the position of the item that will be deleted.
Please note that both methods are promises with .success and .error callbacks.
Tools
Linting with StandardJS
Please refer to the JavaScript Standard Style for general rules.
npm run lint
Unit testing with Karma
npm test
Requirements
Angular
- angular 1.4.3
Qipp modules
- qipp-services-resource 1.0.2
Licence
Released under the MIT license by qipp.