内容简介:你在这里无需担心.新的角度变化检测将为您处理性能,并且每个项目都不应该有活动的侦听器.这是一种常见的模式,不应影响性能.翻译自:https://stackoverflow.com/questions/44452567/angular-delegation-pattern-the-way-to-optimise-handlers-inside-ngfor
例如:我需要输出一个列表.每个项目都有一个(click)处理程序,其中item对象就像参数一样.
<ul>
<li *ngFor="let item of myList">
<button (click)="clickHandler(item)"></button>
</li>
</ul>
此列表将经常动态更新:我将在Scroll上加载新项目,或通过搜索过滤列表.
对于每个项目,Angular都会添加一个事件监听器!
题:
它可能是列表中的很多项,因此很多eventListener将一直连接和断开连接.
有没有办法应用委托模式只有一个eventListener实时?
你在这里无需担心.新的角度变化检测将为您处理性能,并且每个项目都不应该有活动的侦听器.这是一种常见的模式,不应影响性能.
翻译自:https://stackoverflow.com/questions/44452567/angular-delegation-pattern-the-way-to-optimise-handlers-inside-ngfor
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
AI Algorithms, Data Structures, and Idioms in Prolog, Lisp, and
George F. Luger、William A Stubblefield / Addison Wesley / 2008-09-04 / USD 22.20
This book is designed for three primary purposes. The first is as a programming language component of a general class in Artificial Intelligence. From this viewpoint, the authors see as essential that......一起来看看 《AI Algorithms, Data Structures, and Idioms in Prolog, Lisp, and 》 这本书的介绍吧!