Event Binding
// binding.html
<button (click)="sayHello($event)"></button>
<button on-click="sayHello($event)"></button>
import { Component } from '@angular/core';
@Component({
selector: 'selector',
templateUrl: 'binding.html'
})
export class ComponentNameComponent{
sayHello(e){
console.log("saying hello");
// e.target = button dom element
// use e.stopPropogation() if required
}
}
Last updated
Was this helpful?