- Expert Angular
- Mathieu Nayrolles Rajesh Gunasundaram Sridhar Rao
- 79字
- 2021-07-15 17:05:37
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.
推薦閱讀
- 從零構(gòu)建知識(shí)圖譜:技術(shù)、方法與案例
- 基于粒計(jì)算模型的圖像處理
- Building a RESTful Web Service with Spring
- Visual FoxPro 程序設(shè)計(jì)
- Django Design Patterns and Best Practices
- 算法訓(xùn)練營:提高篇(全彩版)
- 深入理解Android:Wi-Fi、NFC和GPS卷
- Protocol-Oriented Programming with Swift
- Visual Basic程序設(shè)計(jì)實(shí)驗(yàn)指導(dǎo)(第二版)
- 從零學(xué)Java設(shè)計(jì)模式
- Mastering Embedded Linux Programming
- 大規(guī)模語言模型開發(fā)基礎(chǔ)與實(shí)踐
- Learning D3.js 5 Mapping(Second Edition)
- 少兒編程輕松學(xué)(全2冊(cè))
- Building Apple Watch Projects