Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!