官术网_书友最值得收藏!

Binding click event

AngularJS provides an event based directive, ng-click, that can bind a click event to a method in an associated controller. Angular achieves the same by using native DOM elements which can be targeted with the ( ) syntax and it accomplishes this by combining One-way Data Binding with the event binding.

AngularJS:

<button ng-click="vm.showBook()"> 
<button ng-click="vm.showBook($event)"> 

Angular:

<button (click)="showBook()"> 
<button (click)="showBook($event)"> 

Notice that in Angular, the target event click is defined inside the parentheses and the method from the component is specified in quotes.

主站蜘蛛池模板: 包头市| 大厂| 阜南县| 莱州市| 大名县| 英德市| 缙云县| 山丹县| 板桥市| 房山区| 浠水县| 色达县| 巢湖市| 庆元县| 南安市| 茌平县| 即墨市| 黄浦区| 桦南县| 柳林县| 高邑县| 永靖县| 德昌县| 西乌珠穆沁旗| 万宁市| 临桂县| 阜城县| 马关县| 莲花县| 若羌县| 衡东县| 鄂伦春自治旗| 正镶白旗| 甘泉县| 吴江市| 资中县| 大名县| 宁化县| 三亚市| 双柏县| 永靖县|