The (click)
event is not working in my component.
HTML:
<button (click)="onClick">Click</button>
Below is the method in my component class.
onClick(): void { console.log('Button Clicked'); }
onClick
should be a function
Try this
<button (click)="onClick()">Click</button>
Here is the working example
https://stackblitz.com/edit/angular-oudvby?file=app/app.component.ts
try this
<button (click)="onClick()">Click</button>
or
<button on-click="onClick()">Click</button>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.