click angular code example
Example 1: onclick event in angular
(click)="myClickFunction($event)"
Example 2: angular click event
<button (click)="FunctionName()">TEST</button>
Example 3: click angular
<button (click)="onSave()">Save</button>
Example 4: button click event listener angular
content_copy
import { HostListener, Component } from "@angular/core";
@Component({
selector: 'app',
template: `<h1>Hello, you have pressed keys {{counter}} number of times!</h1> Press any key to
increment the counter.
<button (click)="resetCounter()">Reset Counter</button>`
})
class AppComponent {
counter = 0;
@HostListener('window:keydown', ['$event'])
handleKeyDown(event: KeyboardEvent) {
this.counter++;
}
resetCounter() {
this.counter = 0;
}
}
Example 5: click binding angular 8
<button (click)="myFunction()"></button>