Useful List of Angular 7 Event Types for Event Binding

Article By Rawat Digamber on

Angular 7 Event Types

I am going to share with you a useful list of Angular 7 Event Types for Event Binding. Angular offers plenty of event types to communicate with your app. Events in Angular 7 helps you to trigger an action on specific condition like click, scroll, hover, focus, submit etc.

Events allow you to trigger your component’s logic within your Angular app.

List of Angular 7 Event Types for Event Binding

// Full list of Angular Events

(click)="myFunction()"      
(dblclick)="myFunction()"   

(submit)="myFunction()"

(blur)="myFunction()"  
(focus)="myFunction()" 

(scroll)="myFunction()"

(cut)="myFunction()"
(copy)="myFunction()"
(paste)="myFunction()"

(keyup)="myFunction()"
(keypress)="myFunction()"
(keydown)="myFunction()"

(mouseup)="myFunction()"
(mousedown)="myFunction()"
(mouseenter)="myFunction()"

(drag)="myFunction()"
(drop)="myFunction()"
(dragover)="myFunction()"

Example of Angular 7 Click Event

Let’s create a demo for event binding, in this small demo we will trigger a function to show text on the console by clicking on a button in Angular app using (click)="myFunction()" method.

Go to your myapp.component.html file and paste the following code.

<button (click)="myFunction()">Click Me</button>

Go to your myapp.component.ts file and paste the following code.

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

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

export class AppComponent {

  // (click)="myFunction()" event trigger this function on click
  myFunction(event) {
    console.log('Hello World');
  }

}

Please find this detailed article on DOM Events by Mozilla.org.

That’s it for now…

If this tutorial has been helpful to you then must share it with others.

If you have any suggestion or feedback to improve this tutorial then you can contact me here.

It will be my pleasure to connect with you on Twitter and LinkedIn

Hello, I'm Digamber Rawat. My goal is to become a problem solver for all those who get stuck in building their architecture and trying to bring them all together by providing free resources on software development.

If my solutions helped you ever then please consider supporting what i do.

Support my work