Tree structure construction is breaking( problem with $digest())

23 views
Skip to first unread message

Venkata Gopi Kolla

unread,
Apr 17, 2015, 11:51:35 AM4/17/15
to ang...@googlegroups.com

We are constructing a tree structure using ng-repeat, for this we are making visual force remote action call to get some large(11000 records) Json data from the back end ,Once we get the data we are binding to scope variable by calling $scope.$apply() to let angular know about this model object(scope variable) change,when $scope.$apply method is called my page is taking too long and even breaking after sometime at $rootscope.$digest() (which is in $apply())...

Any suggestions ?


Thanks,

Venkat.

Luke Kende

unread,
Apr 18, 2015, 3:23:31 AM4/18/15
to ang...@googlegroups.com
I would suggest simplifying.  Here are some ideas to get you thinking..
  • Do you really need to bind all 11000 records at the same time? Maybe add some to the array then add more as a user scrolls down.
  • What are you showing initially?  If you only show parent nodes until a user expands to see children, then you may only need to bind parents, then add data for children as expansion click occurs.
  • Once data is bound, are there other directives firing based on the data? For example, if you have something like ng-class="getClass(row)" then you are adding overhead.  Remove extra functionality until you get things working a little smoother.  Bind to direct data on the objects instead of to functions if applicable. Ex: ng-class="row.class", where row.class is a pre-filled string.
  • Will the data change such that you need to keep all $watch expressions on the collection?  Maybe try something like bind-once: http://ngmodules.org/modules/ng-repeat-once
Hope that gets you going in the right direction.  Good luck!
Reply all
Reply to author
Forward
0 new messages