Useful List of Angular 7 Event Types for Event Binding

By Digamber Rawat Last updated 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

Digamber Rawat
Digamber Rawat

Full stack developer with a passion for UI/UX design. I create beautiful and useful digital products to solve people’s problem and make their life easy.