material icon indicating copy to clipboard operation
material copied to clipboard

md-checkbox triggers ng-click even when it is disabled

Open amerimi opened this issue 11 years ago • 9 comments

Hello,

When md-checkbox is disabled but has an ng-click, the ng-click code gets called when the md-checkbox is clicked.

This is not the case with a normal input checkbox.

<md-checkbox ng-disabled="true" ng-click="update(!item)" aria-label="Disabled checkbox" ng-model="item">
      md-checkbox: Disabled with ng-click
</md-checkbox>

<input type="checkbox" ng-disabled="true" ng-click="update(!item)" ng-model="item" />

Here is a test that shows the issue: http://plnkr.co/edit/t9XO0TGIA5u6m2dym1Fd?p=preview

Thanks in advance

amerimi avatar Apr 25 '15 19:04 amerimi

Same here. Even we are facing the exactly same issue.

vishalkrv avatar Aug 12 '15 11:08 vishalkrv

workaround - add a parent div around the checkbox and disable that http://plnkr.co/edit/nbwsJfe5xBkBGhgoTarE?p=preview

lorezzed avatar Aug 19 '15 07:08 lorezzed

Thanks..

vishalkrv avatar Aug 20 '15 14:08 vishalkrv

+1

mjhasbach avatar Oct 08 '15 09:10 mjhasbach

+1

deepikat avatar Nov 20 '15 18:11 deepikat

+1

belluccifranco avatar Dec 11 '15 02:12 belluccifranco

I have this isssue when i create checkbox dynamically using ng-repeat

[(http://codepen.io/madhavansekar/pen/ZQVzLb)]

kindly suggest some ideas to overcome this issue

madhavanks26 avatar Feb 10 '16 06:02 madhavanks26

Cleanest approach: the ng-click should only execute a single method on the controller, which as its first action does the same check as the ng-disabled and returns immediately if so. Yes, you've duplicated some code, but your controller is no longer depending on the template to do its data sanitization.

DavidSouther avatar Sep 29 '16 18:09 DavidSouther

+1

huangjun604 avatar Oct 10 '16 07:10 huangjun604