【问题标题】:Add Debounce/Throttle to AngularJS ng-repeat filter向 AngularJS ng-repeat 过滤器添加 Debounce/Throttle
【发布时间】:2017-06-24 23:54:45
【问题描述】:

如何在 ng-repeat 过滤器中添加 300 毫秒的 Debounce/Throttle 以提高性能,因为我需要过滤大量对象。请在下面找到示例代码。

<input type="text" ng-model="q" />
<div ng-repeat="user in users | filter : q">
 {{user.name}}
</div>

【问题讨论】:

  • 查看@TheSameSon 评论的链接
  • hadiJz,我已经在此评论之前写下了我的答案。所以你无缘无故地否决了我
  • @EkaterinaTokareva,我给出的答案类似于上述链接中的答案之一。但Jagajit 否决了它。我只是提到这一点。当然,你的回答让我学到了新东西。

标签: angularjs throttling debounce


【解决方案1】:

编写 ng-model-options:

<input type="text" ng-model="q" ng-model-options="{debounce: 300}"/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-16
    • 1970-01-01
    • 2015-12-20
    • 1970-01-01
    • 2015-04-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多