question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

when applying md-button on a button, (click) is not triggered

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Even if a button has the md-button attribute we should be able to bind the click event.

What is the current behavior?

Checkout this line of HTML :

<button
*ngFor="let possibleState of getPossibleStateActions(serviceUnit.state)"
(click)="changeState(possibleState.newStateAfterAction)"
[disabled]="serviceUnit.isUpdatingState"
>
  {{ possibleState.actionName }}
</button>

the changeState function is called.


But if I add md-button or md-raised-button on the button, the design is the one expected but clicking on the button never triggers changeState function.


What are the steps to reproduce?

git clone https://gitlab.com/linagora/petals-cockpit.git
git checkout ab7f5d5816
cd frontend
yarn
ng serve

I did try to reproduce on Plunkr but I couldn’t. I didn’t check the version on Plunkr but maybe Angular is running on 2.x and my project is running 4.0.0-rc.2.

Which versions of Angular, Material, OS, browsers are affected?

4.0.0-rc.2 (didn’t try under that version)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
crisbetocommented, Mar 27, 2017

I haven’t had the chance to look at it yet. I’ll check it out tonight.

2reactions
crisbetocommented, Mar 29, 2017

Yes, I believe that it should be fixed once #3066 is in. You can try out the latest build with this:

npm install https://github.com/angular/material2-builds.git
Read more comments on GitHub >

github_iconTop Results From Across the Web

Client Button Click event not triggered when clicking on button ...
I am using RadToolBar Button with FontAwesome icon and text. When I click on FontAwesome icon on button, it trigger the ...
Read more >
Click() method not working and Console returns an error ...
Output: This error pops up when we click on button B. Example: This example resolves the above TypeError by accessing an individual element....
Read more >
Element: click event - Web APIs | MDN
An element receives a click event when a pointing device button (such as a mouse's primary mouse button) is both pressed and released...
Read more >
When a Click is Not Just a Click | CSS-Tricks
The click event is usually tied to a pointer device, typically the mouse, and yet here the Space or Enter key are triggering...
Read more >
How To Trigger Button Click on Enter - W3Schools
Trigger a button click on keyboard "enter" with JavaScript. Trigger a Button Click on Enter. Press the "Enter" key inside the input field...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found