Básicamente, acabo de comenzar la pila MEAN
Quiero llamar a una función en un clic de botón, esto es lo que estoy tratando de hacer:
este es mi archivo html
<button (click = func())>Click here!</button> este es mi archivo .ts
func(){ console.log("called a function on a button click") }¡Tu ayuda significará mucho para mí!
Hay un problema en su html al vincular el evento de click .
Pruebe el siguiente código:
<button (click)="func()">Click here!</button><button (click)="func()">Click here!</button> func(){ console.log("called a function on a button click") }esto debería funcionar para ti
tu html debería ser así:
<button (click)="func()">Click here!</button>y en tu clase .ts:
func(){ console.log("called a function on a button click") }