Angular 4 Event Binding

当你想从视图中捕获一个事件,你可以通过 使用()包裹事件名来达到。

Angular 提供了大量的事件名 你可以在组件逻辑中使用。

示例:

(focus)="myMethod()"  // An element has received focus
(blur)="myMethod()"   // An element has lost focus

(submit)="myMethod()"  // A submit button has been pressed

(scroll)="myMethod()"

(cut)="myMethod()"
(copy)="myMethod()"
(paste)="myMethod()"

(keydown)="myMethod()"
(keypress)="myMethod()"
(keyup)="myMethod()"

(mouseenter)="myMethod()"
(mousedown)="myMethod()"
(mouseup)="myMethod()"

(click)="myMethod()"
(dblclick)="myMethod()"

(drag)="myMethod()"
(dragover)="myMethod()"
(drop)="myMethod()"

你可以在Mozilla.org 查看更多

参考: Angular 4 Event Binding

==》 掘金小册五折优惠码。记录下 frontendmagazine

你可能感兴趣的:(Angular 4 Event Binding)