0

I have two ckeckboxes and one is disabled when the second one is clicked. I have done it in angularjs but couldn't do the same thing on angular 5 project?

<li>
    <div class="checkbox-inline">
        <input type="checkbox" class="notWorking" ng-model="body.NotWorkShift" ng-disabled="body.All"/>
        <label translate >Notworkshift</label>
    </div>
</li>
<li>
    <div class=" checkbox-inline ">
        <input type="checkbox" class="allCars"  ng-model="body.All"  />
        <label translate>AllCars</label>
    </div>
</li>
Woodrow Barlow
  • 8,477
  • 3
  • 48
  • 86
SANA
  • 669
  • 7
  • 12

1 Answers1

2

Change

<input type="checkbox" class="notWorking" ng-model="body.NotWorkShift" ng-disabled="body.All"/>

to

<input type="checkbox" class="notWorking" ng-model="body.NotWorkShift" [disabled]="body.All"/>
mrkernelpanic
  • 4,268
  • 4
  • 28
  • 52
  • I have tried the same approach and also with [(ngModel)] but i just couldn't make it work – SANA Feb 21 '18 at 07:28
  • ohhh it worked now i needed to define the other inputs as standalone.like this , [(ngModel)]="body.name" [ngModelOptions]="{standalone: true} – SANA Feb 21 '18 at 07:34