AngularJS really slow at rendering with about 2000

2019-01-16 09:26发布

Here's the fiddle: http://jsfiddle.net/D5h7H/7/

It renders the following:

<div ng-repeat="group in Model.Groups">
    <span>{{group.Name}}</span>
    <div ng-repeat="filter in group.Filters">
        <input type="checkbox" ng-model="filter.enabled">{{filter.Name}}
        <select ng-disabled="!filter.enabled">
            <option ng-repeat="value in filter.Values">{{value}}</option>
        </select>
    </div>
</div>

It's a list of filters that is loaded in json from the server and then rendered to the user (in an example json is generated right there in Fiddle). At the moment there are 6 groups of 30 filters in each with 15 option elements for each filter.

In Firefox it now takes about 2 seconds to redraw the UI.

Is this time ok for angular js? Is there anything I'm doing wrong that caused 2sec. rendering (cause 2000 elements doesn't look as a big number to me, but 2sec. is certainly big)?

8条回答
在下西门庆
2楼-- · 2019-01-16 10:04

Using these two angular modules you can make the renderization of your tables much faster.

"quick-ng-repeat" https://github.com/allaud/quick-ng-repeat

"infinite-scroll" https://github.com/infinite-scroll/infinite-scroll

Just be aware this is not a solution to improve the performance of your "ng-repeat", this is just a different approach to make your tables faster.

查看更多
欢心
3楼-- · 2019-01-16 10:05

You should look at bindonce if you don't need to update the UI after the data has been bound to it. bindonce can also wait until an object has been loaded and then do the binding. It will save you a bunch of time and reduce your $watch()es dramatically when used right.

查看更多
登录 后发表回答