If you want to bind an event of type 'click' for all elements that have the same class in the rendered DOM element, you can configure the event listener using the following parts of the code in the components.ts file.
import { Component, OnInit, Renderer, ElementRef} from '@angular/core'; constructor( elementRef: ElementRef, renderer: Renderer) { dragulaService.drop.subscribe((value) => { this.onDrop(value.slice(1)); }); } public onDrop(args) { let [e, el] = args; this.toggleClassComTitle(e,'checked'); } public toggleClassComTitle(el: any, name: string) { el.querySelectorAll('.com-item-title-anchor').forEach( function ( item ) { item.addEventListener('click', function(event) { console.log("item-clicked"); }); }); }
source share