Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
ICSM Computer
30-Mar-2025When dealing with large lists in AngularJS, using pagination or lazy loading can significantly improve performance by reducing the number of items rendered at a time. Here’s how to implement both approaches:
1. Pagination in AngularJS
Method 1: Using
limitToand Custom PaginationYou can use AngularJS’s built-in
limitTofilter along with a pagination mechanism.Example:
Html Code -
Controller:
Method 2: Using
ui.bootstrapPagination ComponentIf you are using Angular UI Bootstrap, you can use its pagination directive:
HTML Code -
Controller :
2. Lazy Loading Large Lists
Lazy loading ensures that only a portion of the data is loaded initially, and more data is fetched as the user scrolls.
Method 1: Using
ngInfiniteScrollngInfiniteScrollis a third-party library that helps in implementing infinite scrolling.Installation:
HTML:
Controller:
Method 2: Server-Side Pagination (API-Based)
If data is fetched from a server, it's best to load data on-demand instead of loading everything at once.
Controller:
Conclusion