-2

I have a very simple html, only containing

<input type="checkbox" value="{{ member.firstName }}" (click)="tick($event)" ng-disabled="true" />

and yet the ng-disabled doesn't work, i.e. checkbox remains enabled.

If I change it to:

<input type="checkbox" value="{{ member.firstName }}" (click)="tick($event)" disabled />

it works, i.e. the checkbox is disabled.

What is wrong with the first line?

StackedQ
  • 3,999
  • 1
  • 27
  • 41
Obay
  • 3,135
  • 15
  • 55
  • 78
  • 1
    Does this answer your question? [Disable Angular 5 Input fields correct way](https://stackoverflow.com/questions/50220643/disable-angular-5-input-fields-correct-way) – Hoang Subin Feb 29 '20 at 14:34

3 Answers3

0

If it's angular it should be [disabled]

<input type="checkbox" value="{{ member.firstName }}" (click)="tick($event)" [disabled]="true" />
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • That works, but my goal was to have something like `[disabled]="enableCheckboxes"` where `enableCheckboxes` is a class variable set to true or false, which now doesn't work. – Obay Feb 29 '20 at 14:05
  • @Obay No issue with your code please check the value of enableCheckboxes is true or false or undefined. – Amit kumar Feb 29 '20 at 14:10
-1

What code editor are you using? I used https://www.plnkr.co and it worked fine. And as hardik said above, are you using the script tag? <input type="checkbox" value="{{ member.firstName }}" (click)="tick($event)" ng-disabled="true" />

shreyasm-dev
  • 2,711
  • 5
  • 16
  • 34
-2

are you including the script as follows in your index.html

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>

if you don't include this script the ng-disabled will not work as ng-disabled is an angular-js directive.