ng-repeat with thousands of elements

2,621 views
Skip to first unread message

Timothy Klim

unread,
Nov 12, 2012, 3:45:52 PM11/12/12
to ang...@googlegroups.com
Hi!

I have service that render thousands of elements with ng-repeat. For me it's take 10 seconds and all this time my browser is frozen. How I can render thousands of elements with asynchronous way and more quickly that 10 seconds?

Thank you.

Ryan Zec

unread,
Nov 12, 2012, 3:49:31 PM11/12/12
to ang...@googlegroups.com
Do you have to load these thousands of items at the same time?  Could you do something like paging or infinite scrolling so you are only loading a small percentage at a time?

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
 
 

Timothy Klim

unread,
Nov 12, 2012, 3:50:46 PM11/12/12
to ang...@googlegroups.com
Do you have to load these thousands of items at the same time?
yes

Could you do something like paging or infinite scrolling so you are only loading a small percentage at a time?
No, because it's specific for this project.

Pawel Kozlowski

unread,
Nov 12, 2012, 3:55:36 PM11/12/12
to ang...@googlegroups.com
Hi!

On Mon, Nov 12, 2012 at 9:50 PM, Timothy Klim <klimt...@gmail.com> wrote:

> Could you do something like paging or infinite scrolling so you are only
> loading a small percentage at a time?
>
> No, because it's specific for this project.

Hmm, you might have a hard time using AngularJS (ng-repeat) as-is for
several thousands of bindings :-(
Have you seen this SO response from Misko?
http://stackoverflow.com/a/9693933/1418796

It rather clearly sets some boundaries within which we can expect
AngularJS to perform well. I mean, AngularJS does so much
heavy-lifting with its dirty checking but it has its cost...

Cheers,
Pawel

Ryan Zec

unread,
Nov 12, 2012, 4:02:34 PM11/12/12
to ang...@googlegroups.com
Maybe the UI is be re-thoughout so that you don't have to display thousands of element to the user at one time.  I mean since I don't know the functionality or the data being displayed I can say for sure but having a UI requiring thousands of elements on the same page seems like it might be flawed.

Misko Hevery

unread,
Nov 12, 2012, 5:05:21 PM11/12/12
to ang...@googlegroups.com
don't use ng-repeat, unsteady write your own html and then render it using ng-unsafe-html

but really that is bad UI. 

Timothy Sweet

unread,
Nov 20, 2012, 4:53:48 PM11/20/12
to ang...@googlegroups.com
maybe using a grid would help? it uses virtual scrolling  http://timothyswt.github.com/ng-grid/examples/ 
-Tim Sweet

Timothy Klim

unread,
Nov 20, 2012, 4:55:50 PM11/20/12
to ang...@googlegroups.com
wow, thank you! I'll try it.

Maxim Grach

unread,
Feb 14, 2013, 1:38:43 AM2/14/13
to ang...@googlegroups.com
Hi, Timothy!

Do you resolve problem with rendering thousands of element with ng-repeat? I have the same issue now. But with some kind of "infinity scroll": script loads first portion (500 objects) and shows them, when user scroll to end of list script loads another portion and etc. But after 5000 I see freezing… 

I understand It's dirty checking but perhaps there is some kind of solution.

вторник, 13 ноября 2012 г., 2:45:52 UTC+6 пользователь Timothy Klim написал:

Saurabh Nanda

unread,
Feb 14, 2013, 2:32:02 AM2/14/13
to ang...@googlegroups.com
There may be situations where you need to display thousands of elements on the page. However, do you need the *two-way data-binding* for all those elements? If not, you can use a custom directive instead of ng-repeat that does NOT set-up a watch on the array/object being repeated. Take a look at the thread at https://groups.google.com/d/topic/angular/xxjcvQIdz5Y/discussion

Maxim Grach

unread,
Feb 14, 2013, 3:08:11 AM2/14/13
to ang...@googlegroups.com
Yeah, I do not need two-way data-binding, I need to display only (It is the navlist of states of object, items of this list are just a links to other view).
Saurabh, thank you for usefull link.

четверг, 14 февраля 2013 г., 13:32:02 UTC+6 пользователь Saurabh Nanda написал:

Timothy Klim

unread,
Feb 14, 2013, 6:24:20 AM2/14/13
to ang...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages