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

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.

主站蜘蛛池模板: 塔城市| 临颍县| 桦甸市| 新蔡县| 商丘市| 陆丰市| 安塞县| 渭南市| 亚东县| 洛南县| 萨迦县| 海南省| 周宁县| 金湖县| 梨树县| 石门县| 乌拉特中旗| 微山县| 义乌市| 明水县| 合水县| 衡阳县| 平乡县| 泌阳县| 瓮安县| 扎兰屯市| 朝阳区| 盐边县| 河西区| 宝兴县| 安平县| 敦化市| 团风县| 韶山市| 邵武市| 武胜县| 剑阁县| 那坡县| 北流市| 安西县| 什邡市|