You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Directive,ElementRef,EventEmitter,HostListener,Output}from'@angular/core';/** * Created by He on 25/12/17. * 点击挂载对象的外部节点,触发事件 */
@Directive({selector: '[appClickOutside]'})exportclassClickOutsideDirective{
@Output()clickOutside=newEventEmitter();constructor(privateelementRef: ElementRef){}
@HostListener('document:click',['$event.target'])publiconClick(targetElement){constclickedInside=this.elementRef.nativeElement.contains(targetElement);if(!clickedInside){this.clickOutside.emit(null);}}}
The text was updated successfully, but these errors were encountered:
场景
click-outside.directive.ts
The text was updated successfully, but these errors were encountered: