MdCheckbox does not pass a change event to change handler
See original GitHub issueBug, feature request, or proposal:
Bug
What is the expected behavior?
The component should return a change event like any regular HTML input element does, too. Interestingly, MdInput does return a regular change event.
What is the current behavior?
When binding an event handler via the (change)=“doSomethingOnChange($event)” notation, the MdCheckbox component does not return a DOM change event when checked/unchecked but a custom angular event, which does not bubble like a change event should.
What are the steps to reproduce?
Simply register a change event handler on an <md-checkbox>
and log the event.
http://plnkr.co/edit/4KRXLDmbHU2pO7RvBiaw?p=preview
What is the use-case or motivation for changing an existing behavior?
The event should bubble just like a regular HTML checkbox’s events bubble so that container elements can catch their events.
Which versions of Angular, Material, OS, browsers are affected?
I tried both 2.0.2 and 2.3.0
Is there anything else we should know?
A fix would be fantastic. We all appreciate your team’s great work!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Angular2 Unit Test - Change event in MdCheckbox is not ...
I can offer you two options: 1) Trigger change event on md-checkbox element it('should call intentChecked on change checkbox', ...
Read more >onchange Event - W3Schools
The onchange event occurs when the value of an element has been changed. For radiobuttons and checkboxes, the onchange event occurs when the...
Read more >Checkbox | Angular Material
Event emitted when the checkbox's indeterminate value changes. defaultColor: ThemePalette | undefined. Default color to fall back to if no value is set....
Read more >How To Use React Checkbox onChange Feature (with Code ...
On its own, our Checkbox component has no way to access its parent element, so we have to explicitly pass in the callback...
Read more >AlertController - Ionic API Documentation
You can pass all of the alert's options in the first argument of the create method: ... If a handler returns false then...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I used both click and change event on mat-checkbox, click for passing the event to stop propagation. The below code worked for me.
<mat-checkbox (change)=“handleProductClick(product)” [checked]=“product.selected” (click)=“$event.stopPropagation()” [id]=“product.id”></mat-checkbox>
Here is nice solution via jquery -
`$(‘md-checkbox.toggle-vis’).on( ‘click’, function (e) {
});`
just install jquery with npm and put below line in component - `import * as jQuery from ‘jquery’;