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

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.

主站蜘蛛池模板: 县级市| 阿克陶县| 寿宁县| 邯郸县| 灵宝市| 景德镇市| 绩溪县| 定陶县| 道孚县| 博白县| 石狮市| 潜山县| 上虞市| 侯马市| 中卫市| 宽城| 永平县| 金川县| 明光市| 永靖县| 瑞金市| 石棉县| 驻马店市| 徐汇区| 基隆市| 上栗县| 绵阳市| 万全县| 新丰县| 丰镇市| 乌什县| 肥西县| 阿拉尔市| 屯留县| 安庆市| 滨州市| 六安市| 长乐市| 荆门市| 云阳县| 山阳县|