AngularJS 'ng-filter' is very slow on array of ~1000 elements

后端 未结 6 1800
半阙折子戏
半阙折子戏 2020-12-23 00:11

I have a simple search filter set up for a list of itemnames in AngularJS.

My list looks like this:

var uniqu         


        
6条回答
  •  死守一世寂寞
    2020-12-23 00:40

    Every time you press key in input all watch expressions need to be executed and looking at your code you have lot of them. If item names are immutable you could use for example https://github.com/abourget/abourget-angular which allows you to write:

    
    

    And you have 1000 less watch expressions to execute on each keystroke.

    Additionally you could use some kind of throttling on input so filter triggers after 500ms from last keystroke.

提交回复
热议问题