2016-02-29 66 views
0

我有一個有角度的應用程序,可以搜索超過1000個對象。正在撕裂用戶界面,應用程序似乎很慢。角度搜索優化

的對象即時通訊通過這個樣子的搜索:

enter image description here

當前陣列IM3通過搜索是799長。

我的搜索方法,到目前爲止已經輸入領域有以下:

<input type="text" class="form-control" placeholder="Søg" ng-model="search.$"> 

正如你可能已經猜到的問題是,即時通訊中的所有文本的搜索。

所以我試圖在question領域本更改爲只搜索:

<input type="text" class="form-control" placeholder="Søg" ng-model="search.question"> 

但是這並沒有多大幫助。當我嘗試在搜索字段中寫入時,用戶界面仍然是「laggy」。

所以我的問題是如何優化此搜索並避免laggy ui?

回答

2

您沒有寫入在輸入字段中輸入內容時實際發生的情況。不管怎麼說,而不是當用戶鍵入她已經停止打字後,您可以搜索,使用ngModelOptions搜索:

<input ng-model-options="{ debounce: 200 }" ng-model="search.question"> 

這將啓動用戶已經停止打字搜索的200ms之後。