Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

close div when click outside angular 7

@Component({
  host: {
    '(document:click)': 'onClick($event)',
  },
})
class SomeComponent() {
  constructor(private _eref: ElementRef) { }

  onClick(event) {
   if (!this._eref.nativeElement.contains(event.target)) // or some similar check
     doSomething();
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: passing html vlaues to Javascript function 
Javascript :: javascript multidimensional array foreach 
Javascript :: axios send post to php 
Javascript :: es6 node 
Javascript :: js capitalize first letter of each word 
Javascript :: document.append 
Javascript :: This version of CLI is only compatible with Angular versions 
Javascript :: javascript indexof with condition 
Javascript :: duplicate numbers in an array javascript 
Javascript :: error An unexpected error occurred: "https://registry.yarnpkg.com/@material-ui/icons/-/icons-4.11.2.tgz: ESOCKETTIMEDOUT". 
Javascript :: jquery set span text by id 
Javascript :: copying object javascript 
Javascript :: what is interpolatin in javascript 
Javascript :: javascript console log whole array 
Javascript :: fromcharcode in javascript 
Javascript :: codeigniter 3 if ajax request 
Javascript :: how to change background color on scroll 
Javascript :: how to convert integer to double in javascript 
Javascript :: how to remove key value pair from object in javascript 
Javascript :: react slick 
Javascript :: javascript keyup event enter key 
Javascript :: checkbox jquery checked 
Javascript :: how to show progress on ajax call 
Javascript :: javascript get array difference 
Javascript :: countdown in js 
Javascript :: vue js cdn 
Javascript :: bootstap jquery 
Javascript :: nodejs routes 
Javascript :: window.addeventlistener 
Javascript :: react render after fetch 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =