angular - 角度 5 中的 mouseup 侦听器
问题描述
我怎样才能实现这个jquery
$(document).mouseup(function (e) {
var container = $("#post-emoji-picker");
// if the target of the click isn't the container nor a descendant of the container
if (!container.is(e.target) && container.has(e.target).length === 0) {
container.hide();
this.toggled = false; //angular didn't compile this
}
});
到角度事件监听器
解决方案
添加一个全局事件目标,例如
<div (window:mousedown)="mouseDown()" (window:mouseup)="mouseUp()"></div>
收听全局事件。(正文和文档也可以工作)。
这当然也适用于组件类
@HostListener('window:mouseup', ['$event'])
mouseUp(event){}
推荐阅读
- excel - VBA Workbooks.Open 崩溃 excel
- ios - 当我从 iCloud 中选择照片时,应用程序崩溃了
- vue.js - 上传不同尺寸的相同图像 - Dropzonejs
- java - 无法使用 Java 读取复杂的 XML 深层嵌套结构
- android - RecyclerView 中的缩放中心项
- c# - 我在 C# 中重新定位我的对象时遇到问题
- material-ui - Material-UI - 使用嵌套弹出框悬停时保持打开的工具提示
- css - IOS中的离子搜索背景颜色
- c# - 有没有办法强制 Hangfire 每次都再次执行代码?
- angular7 - Angular 7视图初始化多次触发调用