- 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.
推薦閱讀
- Practical Data Analysis Cookbook
- CockroachDB權威指南
- Mastering Kotlin
- Learning AWS Lumberyard Game Development
- Scala編程實戰(原書第2版)
- 學習正則表達式
- Learning SciPy for Numerical and Scientific Computing(Second Edition)
- Python機器學習算法: 原理、實現與案例
- 區塊鏈技術與應用
- ASP.NET程序開發范例寶典
- Java Web從入門到精通(第3版)
- Windows Phone 8 Game Development
- Visual Basic程序設計全程指南
- Learning Concurrency in Python
- Node.js 6.x Blueprints