Material: md-checkbox with ng-disabled allowing select & deselect

Created on 28 Sep 2015  路  3Comments  路  Source: angular/material

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

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;
}
};

All 3 comments

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;
}
};

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikhildev picture nikhildev  路  3Comments

epelc picture epelc  路  3Comments

LeoLozes picture LeoLozes  路  3Comments

bobber205 picture bobber205  路  3Comments

vladimir-barsuchenko picture vladimir-barsuchenko  路  3Comments