Bug
When using native checkboxes with Angular2-Data-Table I can toggle columns on or off the table.
When trying to implement md-checkbox the first click doesn't work - the checkbox remains checked.
After the first click the checked value is opposite to the model, i.e. opposite to the native checkboxes.
I tried many ways to fix this but without luck. this seems to be a bug in md-checkbox.
see plunker :
https://plnkr.co/edit/HGUjy5
The first click should toggle the checkbox correctly.
Providing a Plunker (or similar) is the best way to get the team to see your issue.
Plunker template: https://plnkr.co/edit/HGUjy5
Angular 2.1.2
latest Angular 2 Material
@tinayuangao can you reproduce this?
This is not a bug in md-checkbox. Your isChecked(col) needs to return a boolean to make it work - now it returns {name: ColName}.
The correct isChecked(col) function should be isColChecked(col:any) {
return this.columns.find(c => {
return c.name === col.name;
}) != undefined;
}
You also need to change (click)="toggle(col)" in template to (change)=toggle(col). The (change) event in MdCheckbox will toggle the checkbox again.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
You also need to change
(click)="toggle(col)"in template to(change)=toggle(col). The(change)event in MdCheckbox will toggle the checkbox again.