I am using a md-checkbox with ng-click & ng-checked. When i add ng-disabled, even though it looks like disabled it is allowing to select & deselect the check box.
Please refer the codepen.
https://codepen.io/anon/pen/gaLQyK
I just added ng-disabled="true" to the sample given here(md-checkbox with ng-checked)
https://material.angularjs.org/latest/#/demo/material.components.checkbox
The problem is that the checkboxes in the demo are using ng-click
to do an additional toggle, separate from the internal click handler that toggles the checkbox. You generally want to avoid duplicating the logic that is contained within the components.
However, the native checkbox does not fire click events when it is disabled, so md-checkbox
should do the same. Fixed in #4939
Thanks
You can still restrict selecting the checkbox while using ng-click by returning false from the ng-click function based on a condition. For example
clickMethod = function(item){
//To Restrict clicking disabled checkboxes
if(some_relevant_condition){
return false;
}
};
Most helpful comment
You can still restrict selecting the checkbox while using ng-click by returning false from the ng-click function based on a condition. For example
clickMethod = function(item){
//To Restrict clicking disabled checkboxes
if(some_relevant_condition){
return false;
}
};