Listen to click event on Angular component

Viewed 24588

How to listen to click event on the component and call a method on the component?

Ex -

Component

import { Component } from '@angular/core';

@Component({
  selector: 'my-component',
  template: `
    <div>Hello my name is {{name}}. </div>
   `
})
export class MyComponent {
  name = "Aj"
}

HTML -

<my-component></my-component> // user clicks here

Now how do I listen to click on the component itself?

3 Answers
Related