How do I implement progressive loading of content as you scroll down the page? Otherwise 1000 images would load at the same time.
Progressive loading in ng-repeat for images, angular js
39.3k views Asked by TheNickyYo At
2
There are 2 answers
2
EpokK
On
Use infinite scrolling directive. ngInfiniteScroll
HTML
<div ng-app='myApp' ng-controller='DemoController'>
<div infinite-scroll='loadMore()' infinite-scroll-distance='2'>
<img ng-repeat='image in images' ng-src='http://placehold.it/225x250&text={{image}}'>
</div>
</div>
JS
var myApp = angular.module('myApp', ['infinite-scroll']);
myApp.controller('DemoController', function($scope) {
$scope.images = [1, 2, 3, 4, 5, 6, 7, 8];
$scope.loadMore = function() {
var last = $scope.images[$scope.images.length - 1];
for(var i = 1; i <= 8; i++) {
$scope.images.push(last + i);
}
};
});
Related Questions in ANGULARJS
- How to automatically change path in angular when scrolling
- Error two clicks to be able to login Angular 16
- Passing an array of objects through the $http.post method in angular JS does not work
- Understanding how to apply Angular Signals from beginning on an existing service
- provider duplicate while compiling a Cordova application for the Android platform
- How can I use angularjs $parse service in Angular?
- Width of custom headers in ag-grid (angular) doesn't match with column's width
- Issues with Katex/ngx-markdown Rendering in Angular 16
- How to make Angular SSR wait for async operations to finish that are initiated in ngOnInit?
- I want to install @angular/google-maps npm Package in angular 16.2.12 but "npm install @angular/google-maps" this is not working/ tell me other query
- Angular 17 standalone application integrate CKEditor 5 -- Error: window is not defined
- Why is $scope >= 0 showing true in interpolation while empty in controller?
- The XMLHttpRequest compatibility library was not found
- Making Gantt Chart Column Labels More Readable
- Pass key-value pairs of object as individual arguments to component in Angular
Related Questions in LAZY-LOADING
- use suspense and lazy loading but with more delay between each
- Video lazy load - background
- Can I use another lazy component as <Suspense /> fallback?
- PrimeNG p-table lazy load does not update without extra 'click'
- Bundle size after migrating to all standalone and implementing lazy loading
- EF Core 8 : getting grand children from grandparent
- Why does adding lazy loading to a React Vite project result in an empty root node?
- window.scrollBy And window.scrollTo is not working in edge..We used lazy loader from bakend for little scroll i used window.scroll
- OneToOne mapping leading to performance impact due to N+1 select issue
- Preload all components when lazy loading standalone components for routing
- React.lazy doesn't improve lighthouse or PageSpeed Insights score. Is it a problem actually?
- Can't get image URLs from lazy-loaded page source
- How to import react-icons module using lazyloading using a variable
- PagespeedInsights shows defer offscreen images even when image is lazy loaded?
- ChunkLoadError: Loading chunk X failed
Related Questions in ANGULARJS-NG-REPEAT
- AngularJS ng-repeat overwrites table results on collapse / expand panels
- AngularJS (1.5.0) nested ng-repeat with radio button not initializing checked properly
- Javascript do-while loop condition causing error
- ng-repeat going into infinite loop on array of objects
- angularjs understanding ng-repeat behavior in Modal
- how to append items to the same row or line with ng-repeat (How to use ng- repeat in angular js)
- How to have multiple rows in a ng-repeat
- How I suppose to break 10 k records in ng-repeat in HTML table?
- different image url each profile (ng-repeat)(ng-src)
- AngularJS : table rowspan dynamic
- how to filter table data using angularJS filter from a selection value
- why is ng-repeat not working in custom directive?
- ng-if or ng-repeat in angularjs remove web-components from DOM
- ng-isolate-scope in each child directive along with ng-repeat in AngularJS
- show more in AngularJS dropdown
Related Questions in PROGRESSIVE
- PWA App open manifest.json instead of page when installed on Chrome
- Ruby : combined if statements : why does my code always prints the same value ? (Example : progressive tax scale)
- Progressive web apps and ASP.net routing
- PWA (Uncaught (in promise) TypeError: Request failed) error
- How to keep direct link for installation PWA
- How to store data in Progressive Web Applications in .Net core 2.1?
- How can I force service worker to clear cache?
- Is progressive jpeg a good solution for fast loading images?
- Partial Views in Progressive Web App
- Progressive Web App no longer updating after iOS 11.3
- Eloqua Forms - Progresive Profie / Profiling
- How do I open iframe links in parent window on android native app?
- Load Progressive Web App inside iframe
- Add "badge notification" for progressive web application (PWA)
- url showing in address bar in progressive web apps
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
I didn't want to use
ngInfiniteScrollthe other guy posted as my mobile app does not use jQuery so there is no point in loading it just for this.Anyhow, I found a jsfiddle with pure Javascript that solves this problem.
HTML
JavaScript
Source: http://jsfiddle.net/vojtajina/U7Bz9/