npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngconf-pagination

v1.1.0

Published

Angular Library to provide Pagination with Search Feature to Angular apps.

Downloads

9

Readme

Ngconf-Pagination Library

This project was generated with Angular CLI version 11.0.2.

ngconf-pagination 1 of 5 ngconf-pagination Pagination Feature with search functionality for Angular.

Latest Release:

Now you can customize the color schemes of Pagination controls component.
Now we added support for special characters search by removing them from search index process for better results.
Now we updated the package to latest angular version.
Added page tabs support for pagination control component and changed the input configurations for that component.

Demo Link

Stackblitz Demo

Step - 1

npm i ngconf-pagination --save
NPM Package Link

Step - 2

Import NgconfPaginationModule in app.module.ts file.

app.module.ts

import {NgconfPaginationModule} from 'ngconf-pagination';
 imports: [
    BrowserModule,
    AppRoutingModule,
    NgconfPaginationModule,
    HttpClientModule
  ]

Step - 3

This step is to quick start the usage of package later with the understanding of workflow you can
modify the code. You can have a look in our stackbliz demo for more clarity. Json typicode dummy data api is used to show that this package can handle asynchronous data. app.component.ts

  tableArray:Array<any> = [];
  currentPage:any = 1;
  itemsPerPage:any = 10;
  totalPage:any = 0;
  term:any = "";
  prop:any = "";
  pageTabs: boolean = true;
    stylingProps:any = {
    backgroundColor: "#fff",
    textColor: "blue",
    activeBackgroundColor: "green",
    activeTextColor: "#fff",
    onHoverBackgroundColor: "#e9ecef",
    onHoverTextColor: "#0056b3"
  };
  constructor(private http: HttpClient){

  } 
  ngOnInit(){
  this.http.get("https://jsonplaceholder.typicode.com/comments")
  .subscribe(res => {
     let temp:any = res;
     this.tableArray = temp;
  });
    
  }

app.component.html

  <input type="text" [(ngModel)]="term" [value]="term" placeholder="Search">
  <br>
  <label class="mt-3" for="fill">Searh Based On:</label>
  <select class="ml-2" [(ngModel)]="prop" id="fill">
    <option  value="" selected>All</option>
    <option value="id">ID</option>
    <option value="name">Name</option>
    <option value="email">Email</option>
    <option value="body">Body</option>
  </select>
  <div class="table-responsive" *ngIf="tableArray.length > 0">
    <table class="table table-striped">
      <thead>
        <tr>
          <th scope="col">ID</th>
          <th scope="col">Name</th>
          <th scope="col">Email</th>
          <th scope="col">Body</th>
        </tr>
      </thead>
      <tbody>
        <tr *ngFor="let item of tableArray  | paginator: { elementsPerPage: itemsPerPage, currentPage: currentPage,searchTerm: term, prop: prop  } " >
          <th scope="row">{{item.id}}</th>
          <td>{{item.name}}</td>
          <td>{{item.email}}</td>
          <td>{{item.body}}</td>
        </tr>
        
      </tbody>
    </table>
  </div>
 <pagination-controls *ngIf="term == ''" [stlyling]="stylingProps"  (pageChange)="currentPage = $event" [controls]="{currentPage: currentPage,itemsPerPage: itemsPerPage,dataLength: tableArray.length,pageTabs:  pageTabs }"></pagination-controls>

Explanation on paginator pipe inputs

1 elementsPerPage this input is used to specify the items per page like 10,5 and 20 etc to divide the data.
2 currentPage This input is used to specify the current page so that accordingly pipe transforms the data.
3 searchTerm This input is used to take user search input and show the results by applying it on the data.
4. prop This input property is used to take specific table field to search.It can be left with empty string to search on all fields.
Structure of the configuration interface for reference.

export interface opt {
  elementsPerPage: Number;
  currentPage: Number;
  searchTerm: String;
  prop: String;
}

Explanation on paginator controls component inputs

1 currentPage This input is to specify the component the current page.
2 itemsPerPage This input is used to specify the items per page to the component.
3 dataLength This input is used to caluculate the total pages based on data length and items per page.

/**
 * The below are the two input property configuration interfaces for reference they  * are pretty much self explanatory.
 * Note: The intefaces for Paginator pipe are different. The below are for pagination * controls.
 * Input property is "controls" for <pagination-controls> <pagination-controls/>   
 * component
 * */
export interface opt{
    currentPage:any;
    itemsPerPage:any;
    dataLength:any;
    pageTabs:boolean  
}
/**
 * Input property is "stlyling" for <pagination-controls> <pagination-controls/>   
 * component
 * */
export interface stylingProps {
  backgroundColor: string,
  textColor: string,
  activeBackgroundColor: string,
  activeTextColor: string,
  onHoverBackgroundColor: string,
  onHoverTextColor: string
}

Styling Suggestion

If you want to have your own page control component then you can use your component and use the above parameters to caluculate the total pages and current page change functionality.

That's it you are good to go. Happy Coding :)