DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Data
  4. Tips for Building Angular Apps on Large Data Sets

Tips for Building Angular Apps on Large Data Sets

Itay Herskovits user avatar by
Itay Herskovits
·
Feb. 06, 15 · Interview
Like (0)
Save
Tweet
Share
12.83K Views

Join the DZone community and get the full member experience.

Join For Free

Web applications often need to work with lots of data. While AngularJS has the capability to search and manipulate large sets of objects, that doesn’t necessarily mean that it should. With other frameworks that are already purpose-built for searching and manipulating large object sets, using AngularJS intelligently can help prevent needlessly storing large amounts of data that consume both excessive processing time and browser process memory. Below we’ll look at a few techniques for dealing with Angular applications built on top of large data sets, and how you can present data the way you like without introducing needless load on your frontend.

Pagination and Infinite Scroll

Any website’s first approach to load management typically centers around pagination. Pagination is the process of grabbing small batches of records (say 25 or so) and displaying them in sequence, as a number of 25-entry pages of results. Instead of dealing with the problem of large numbers of records head-on, this circumvents handling the load by cutting the large number of results into smaller/manageable pieces. This can be done a number of ways – one of the most common is by implementing user-driven navigation (clickable page numbers at the bottom or top of the list). Each click fires off an AJAX call that retrieves the next batch from the server.

Another approach – one a bit more in line with Angular’s principles of letting the data drive the presentation – is the infinite scroll method. AngularJS provides a number of tools that make implementing an infinite scroll a snap. Once a certain record in the set has been reached, then an AJAX call is automatically initiated by the backend to fetch the next page of records, which are then displayed to the user as they continue to scroll. The seamless page integration is in some ways a design choice, but this approach does raise a problem: what should be done with the previous page’s contents in memory? Unfortunately the answer to that question isn’t simple, so we’ll leave it as something to be determined based upon your application’s architecture.

Plugins and Optimization

In some cases, though, pagination is just not suitable. Many individuals may prefer an approach that presents large numbers of records to the user at once (it’s been reported that many in the financial industry prefer large grids of text and numbers, for example). In that case, the approach to take is to manage the usage of resources by AngularJS such that the absolute minimum of processing is done on these items. There are some plugins, like ng-grid, that support larger data sets, though as with any community-supported product the quality of the code may vary widely.

Aside from using a plugin, your development should be focused on understanding how best to present the data, and which directives are going to do more costly work with the data stored in memory. If you absolutely need to present large amounts of data to the end user, you’ll first want to set up a performance testing environment. Some browsers – like Chrome – have one built into their developer tools, but in other scenarios you may need to look at third-party products to performance test and instrument your Angular code. Once this is done, you’ll have a good idea of where your JavaScript is getting bogged down. From there the options are highly dependent on your goals – limiting (or eliminating) two-way binding can provide an immediate performance improvement, for example, as well as removing any inline data calculation being performed. With large data sets the amount of time an action takes is directly proportional to the effort required to perform it, so your efforts should focus on reducing that required effort.

Conclusion

As with any programming effort, a little up-front analysis can go a long way towards reducing headaches at deploy time. One of the common misconceptions about AngularJS is that it is best for single-shot webpages with small amounts of data to show, and common wisdom holds that for heavy record processing and display you may be better off moving the related functionality to the backend. However, as we have seen above, simple design choices and smart approaches to how you write your AngularJS code can have a major impact on the performance of your web application when placed on top of very large data sets, making Angular an excellent choice in these situations.

Build your Angular app and connect it to any database with Backand today. – Get started now.
Data (computing) AngularJS Database app Web application

Published at DZone with permission of Itay Herskovits, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Secrets Management
  • Data Mesh vs. Data Fabric: A Tale of Two New Data Paradigms
  • DevOps Roadmap for 2022
  • Three SQL Keywords in QuestDB for Finding Missing Data

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: