- 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.
推薦閱讀
- Data Visualization with D3 4.x Cookbook(Second Edition)
- Go Web編程
- Delphi程序設(shè)計(jì)基礎(chǔ):教程、實(shí)驗(yàn)、習(xí)題
- Python數(shù)據(jù)分析基礎(chǔ)
- Mastering Selenium WebDriver
- Animate CC二維動畫設(shè)計(jì)與制作(微課版)
- Java面向?qū)ο蟪绦蜷_發(fā)及實(shí)戰(zhàn)
- Python Geospatial Development(Second Edition)
- C語言程序設(shè)計(jì)案例精粹
- Mastering Docker
- C++ Application Development with Code:Blocks
- Kotlin Programming By Example
- WildFly Cookbook
- Instant Automapper
- Learning C++ by Creating Games with UE4