![](/img/trans.png)
[英]What is the proper way to unbind event listeners and remove child elements in single page applications?
[英]What is the proper way to attach event listeners to elements inside a component template?
我有一個包含輸入框的簡單SearchWidgetComponent。 這還將使用li
元素顯示搜索結果。 我需要將不同的事件偵聽器附加到輸入框,例如擊鍵,擊鍵,焦點和模糊。 我還需要在li
元素上附加鼠標事件。
將這些事件偵聽器附加到組件內部的這些元素的正確方法是什么?
您是否看過事件綁定? https://angular.io/guide/user-input
<input id="productNameId"
type="text"
[(ngModel)] = product.productName
(keyup) = "onKeyUp()"
name="productName" />
您是否嘗試過filter
?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.