Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

bind an event to dom element angular

import { AfterViewInit, Component, ElementRef} from '@angular/core';

constructor(private elementRef:ElementRef) {}

ngAfterViewInit() {
  this.elementRef.nativeElement.querySelector('my-element')
                                .addEventListener('click', this.onClick.bind(this));
}

onClick(event) {
  console.log(event);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to make a random if else in js 
Javascript :: select field in react native 
Javascript :: javascript create node from innerhtml 
Javascript :: node js response header 
Javascript :: how to appendChild in the begin of the div javascript 
Javascript :: for each loop with arrowfunction 
Javascript :: store images in mongoose 
Javascript :: how to create package.json file in vs code 
Javascript :: netmask /24 
Javascript :: javascript slice vs splice 
Javascript :: get specific parent element jquery 
Javascript :: javascript array delete first element 
Javascript :: bin2hex in js 
Javascript :: get image as blob 
Javascript :: jquery import js file 
Javascript :: django ajax body to json 
Javascript :: send csrf token ajax laravel 
Javascript :: how to disable and enable a button in jquery 
Javascript :: sequelize migration 
Javascript :: window.onscroll 
Javascript :: how to remove an class in javascript 
Javascript :: how to loop trough an object java script 
Javascript :: jquery select element after this 
Javascript :: React Native Starting In Android 
Javascript :: read url param data in javascript 
Javascript :: array asociativo multidimensional javascript 
Javascript :: javascript insert html before element 
Javascript :: angularjs onclick 
Javascript :: js encryption 
Javascript :: check array values equal js 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =