text: Q:
  
  Angular way of binding function to event for all elements in a class
  
  With jquery we can do something like 
  $(.some-class).click(function() { alert('Hello!!');});
  
  With Angular2 / Angular4 , I know we can have 
  (click)="alert('Hello!!');" 
  
  but this mean, I have to do it for each element.
  Is there a way to assign the same method to all the elements with the same class?
  EDIT: I don't want to select the elements by class rather, have the same function binded to the click event for all elements with the same class.
  
  A:
  
  you can do it like below,
  import { Component, Directive, ElementRef, HostListener } from '@angular/core';
  
  @Directive({
    selector: '.some-class'
  })
  export class SomeClassDirective {
    constructor(private el: ElementRef) { }
    @HostListener('click') onClick() {
      console.log('Hello');
    }
  }
  
  @Component({
    selector: 'my-app',
    template: `<h1>Hello {{name}}</h1>
    <div class='some-class' >added some-class css class attribute</div>
    `
  })
  export class AppComponent { 
    name = 'Angular'; 
  }
  
  Check this Plunker
  Hope this helps!!
  
  