components: checkbox event.target.checked undefined
Bug, feature request, or proposal:
Bug
What is the expected behavior?
<md-checkbox (click)="test($event)"></md-checkbox>
test(event) {
console.log(event.target.checked); // true | false
}
What is the current behavior?
<md-checkbox (click)="test($event)"></md-checkbox>
test(event) {
console.log(event.target.checked); // undefined
}
Which versions of Angular, Material, OS, browsers are affected?
@angular2-material/checkbox@2.0.0-alpha.7-2 @angular/core@2.0.0-rc.5 @angular/forms@0.3.0
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 17 (5 by maintainers)
This works properly for me:
try this: ツ
hello, try
<md-checkbox (click)="test($event)"></md-checkbox>
Hm, I was looking at this issue, and it looks like the
target
in theMouseEvent
is not the underlaying inputI think this is an issue which is solvable, but would rather make the components more complex than they need.
As a workaround I propose the
change
event, because it will be triggered when a click was recognized on the underlaying input.The workaround with
change
is easy to implement in my case, so I’m not sure if this would be a problem for someone or not. Just wanted to address this missmatch on normal behaviour and difference in md-checkbox versions 😃How can we get the native event? I have a situation where I want to stop propagation of my event to parent? But I am not able to get that event.
It worked on the eariler version of md-checkbox and the normal
<input type="checkbox" (click)="test($event)">
works, so shouldn’t the behaviour be the same?