html - 避免事件冒泡问题,以便在 IE11 中使用预输入查看更多选项
问题描述
我有一个输入搜索组件,其中有一个预先输入的输入字段。输入搜索.component.html
<input [typeahead]="data" [typeaheadItemTemplate]="sampleTemplate" (typeaheadOnSelect)="selectedListItem(event$)"/>
并且示例模板有一个文本字段来显示数据,最后它有一个查看全部按钮。
<ng-template #sampleTemplate let-model ="item" let-index="index"><label>model.name</label><button *ngIf="index === maximumCount" (click)="callSeeAllFunction()"> see all results</button></ng-template>
因此,如果我们单击任何列表项 selectedListItem(event$) 将被触发。不幸的是,单击查看所有结果 selectedListItem(event$) 被调用,而不是 IE11 中的 callSeeAllFunction()。
在 callSeeAllFunction() 函数中添加了 event.stopPropagation()。
解决方案
推荐阅读
- c - 不能在函数中使用 malloc 两次
- spring-boot - Spring boot - 如何禁用每个数据源的 Flyway
- c++ - 对于模板 c++ 的每个属性
- javascript - 嵌套异步/等待执行后如何执行函数
- node.js - 有没有办法基于同级属性在 jsonschema 中创建枚举?
- sql-server - 根据条件获取上述行的值
- aws-api-gateway - 具有认知身份验证的 API 网关中的火炮测试
- php - 如何在此 Wordpress 滑块上将最小值设置为零
- vue.js - 即使使用 set,Vue 也不会重新渲染列表
- flutter - 日文日期的格式