Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

element on click listener renderer2 angular2

export class MyComponent implements OnInit, OnDestroy {

  public removeEventListener: () => void;

  constructor(
    private renderer: Renderer2, 
    private elementRef: ElementRef
  ) {
  }

  public ngOnInit() {
    this.removeEventListener = this.renderer.listen(this.elementRef.nativeElement, 'click', (event) => {
      // Write your code...
    });
  }

  public ngOnDestroy() {
    this.removeEventListener();
  }
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: set array of objects in localstorage 
Typescript :: python retrieve name of sheets in workbook 
Typescript :: district affected by latur earthquake 
Typescript :: adonis auth register 
Typescript :: merge properties of object typescript 
Typescript :: shortcuts for ajax in vscode 
Typescript :: list the constituents of the xylem. what would happen if the xylem of root of a plant is blocked? 
Typescript :: according to all known laws of aviation 
Typescript :: psycopg2 OperationalError: FATAL: unsupported frontend protocol 1234.5679: server supports 2.0 to 3.0 
Typescript :: set image on server with changing 
Typescript :: session not created: This version of ChromeDriver only supports Chrome version 85 
Typescript :: install ng bootstrap 
Typescript :: sklearn tsne 
Typescript :: nestjs ratelimit 
Typescript :: fjnction by parts latex 
Typescript :: angular get item from localstorage 
Typescript :: how to use type in batch 
Typescript :: how to configure email alerts in grafana container 
Typescript :: angular array filter typescript 
Typescript :: subtracting two date objects in javacript 
Typescript :: ts remove first 0 number from string 
Typescript :: script to see what tkinter fonts installed on system 
Typescript :: typescript map list to new list of objects 
Typescript :: typescript array of possible object keys 
Typescript :: typescript check undefined 
Typescript :: wordpress query to get posts by post meta 
Typescript :: converting an image to base64 in angular 
Typescript :: recharts bar chart 
Typescript :: flutter firebase notification token 
Typescript :: import images angular 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =