How to get mouseup outside of the component in Angular 2

后端 未结 4 1885
一生所求
一生所求 2021-01-12 01:03

I have a abc component (part of the page). It has an event mouseup.

@Component({
    selector: \'abc-component\'
})
@View({
    
4条回答
  •  伪装坚强ぢ
    2021-01-12 01:27

    A component can access events through the window and document objects. So you could set up an event listener in the component's constructor:

    constructor() {
      document.body.addEventListener("mouseup", () => { 
        this.mouseup(); 
      });
    }
    

提交回复
热议问题