Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sibiraj-s/angular-paginator
📖 Pagination Component for Angular applications
https://github.com/sibiraj-s/angular-paginator
angular angular-paginator pagination
Last synced: 17 days ago
JSON representation
📖 Pagination Component for Angular applications
- Host: GitHub
- URL: https://github.com/sibiraj-s/angular-paginator
- Owner: sibiraj-s
- License: mit
- Created: 2020-04-24T05:45:46.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-05T12:27:19.000Z (11 months ago)
- Last Synced: 2024-05-02T00:01:06.199Z (9 months ago)
- Topics: angular, angular-paginator, pagination
- Language: TypeScript
- Homepage: https://sibiraj-s.github.io/angular-paginator/
- Size: 5.6 MB
- Stars: 4
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-angular - angular-paginator - Pagination Component for Angular applications. (Table of contents / Third Party Components)
- fucking-awesome-angular - angular-paginator - Pagination Component for Angular applications. (Table of contents / Third Party Components)
README
Angular Paginator
Pagination for Angular applications
## Getting Started
[edit in stackblitz](https://stackblitz.com/edit/angular-paginator)
### Installation
Install via package managers such as [npm][npm] or [yarn][yarn]
```bash
npm install angular-paginator --save
# or
yarn add angular-paginator
```### Usage
Import the `angular-paginator` module
```ts
import { AngularPaginatorModule } from 'angular-paginator';@NgModule({
imports: [AngularPaginatorModule],
})
export class AppModule {}
```and in the template
```html
{{(currentPage - 1) * itemsPerPage + i +1}}. {{item}}```
### Paginator Pipe
The `angularPaginator` pipe accepts
```bash
{
id: 'ANGULAR_PAGINATOR_DEFAULT',
itemsPerPage: 10,
currentPage: currentPage
}
```- **id:** The default id is `ANGULAR_PAGINATOR_DEFAULT` when not specified. This is optional. Provide a unique id when multiple pagination instances are being used.
- **itemsPerPage:** Number of items per page
- **currentPage:** Current page number> [!IMPORTANT]
> When using an id, ensure to provide the same id in both the pipe and directive of the same instance.### Paginator Directive
```html
```
- **id:** The default id is `ANGULAR_PAGINATOR_DEFAULT` when not specified. This is optional. This must be provided if the id is specified in the pipe and should be the same as the pipe id
- **maxSize:** Limit number for pagination size
- **rotate:** Whether to keep the current page in the middle of the visible ones
- **boundaryLinkNumbers:** Whether to always display the first and last page numbers. If maxSize is smaller than the number of pages, then the first and last page numbers are still shown with ellipses in-between as necessary.
- **forceEllipses:** Also displays ellipses when rotate is true and maxSize is smaller than the number of pages> [!NOTE]
> maxSize refers to the center of the range. This option may add up to 2 more numbers on each side of the displayed range for the end value and what would be an ellipsis but is replaced by a number because it is sequential#### API
You can get access to the pagination instance(directive's api) using `#paginator="angularPaginator"`. The following are the methods/properties available via the API
- **pages** - Array of page objects.
```ts
interface Page {
number: number;
text: string;
active: boolean;
}
```- **toPreviousPage()** - Sets the current page to previous (`currentPage - 1`)
- **toNextPage()** - Sets the current page to next (`currentPage + 1`)
- **toFirstPage()** - Sets the first page as current
- **toLastPage()** - Sets the last page as current
- **setCurrentPage(val)** - Sets the given page as current page.
- **currentPage** - Returns the current page number
- **firstPage** - Returns the first page number
- **lastPage** - Returns the last page number[npm]: https://www.npmjs.com/
[yarn]: https://yarnpkg.com/lang/en/
[github]: https://sibiraj-s.github.io/