Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda