Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
How can I call a function when clicked on a button?

Basically I have just started MEAN stack

I want to call a function on a button click this is what I am trying to do :

this is my html file

<button (click = func())>Click here!</button>

this is my .ts file

func(){
console.log("called a function on a button click")
}

your help will mean me a lot!

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

There is an issue in your html while binding click event.

Try below code:

<button (click)="func()">Click here!</button>
about 4 years ago · Juan Pablo Isaza Denunciar

0

<button (click)="func()">Click here!</button>


func(){
console.log("called a function on a button click")
}

this should work for you

about 4 years ago · Juan Pablo Isaza Denunciar

0

you html should be like this :

<button (click)="func()">Click here!</button>

and in you .ts class :

func(){
console.log("called a function on a button click")
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda