Topic: how to run a function onclicking button in MDBootstrap (Angular)

Shashank Gour free asked 5 years ago

Hello Damian, Please check the below code this is not working actually. html <button (click)="btnClick();" class="btn btn-primary" mdbRippleRadius>Get Your Quotation </button> function btnClick=function () { this.router.navigateByUrl('contactus'); }; Regards, Shashank

Shashank Gour free commented 5 years ago

Damian, waiting for your reply ????

Damian Gemza staff commented 5 years ago

Dear Shashank, Please notice that I do not constantly monitor the forum, but I am doing my best to help everyone. So if someone from our team doesn't reply to your ticket in few minutes, please wait patiently. Best Regards, Damian

Damian Gemza staff answered 5 years ago

Dear Shashank, In Typescript functions should look as follows: 1st way:
btnClick= () => {

alert('Function was released');

2nd way:
btnClick() {

alert('Function was released');

I've tested your function, but replaced this.router.navigateByUrl('contactus'); with alert(), and everything works fine. So there's something wrong with this.router.navigateByUrl('contactus');
If i could advice you something - if you need routing in your app, use Angular Routing:
Best Regards,

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • User: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No