Gary Bushey
Gary Bushey

Reputation: 121

Angular2 one radio button not disabled

I have a series of radio buttons on a page that are grouped into a collection of "yes"/No" buttons. I want to disable them based on the value of a variable but only the "Yes" button gets disabled when I go to the page. I also have a drop down that changes the variables the ngModel is looking at (the "selectedIndex" variable in the code below) and if I use that drop down to select a different value and then reselect the original value both buttons are disabled. I know the code for the [disabled] is working since it works on the "Yes" button, just not the "No" button. Any ideas?

<div class="col-sm-2">
  <input type="radio"
        name="NewSites"
        id="newsitesyes"
        required="required"
        [value]="true"
     [(ngModel)]="quarterlyInfo[selectedIndex].NewSitesOrSitesNoLongerParticipating"
        [disabled]="quarterlyInfo[selectedIndex].StudyDataLocked" />
  <label for="newsitesno">Yes</label>
  <input type="radio"
        name="NewSites"
        id="newsitesyes"
        required="required"
        [value]="false"
 [(ngModel)]="quarterlyInfo[selectedIndex].NewSitesOrSitesNoLongerParticipating"
        [disabled]="quarterlyInfo[selectedIndex].StudyDataLocked" />
  <label for="newsitesno">No</label>
</div>

Upvotes: 2

Views: 913

Answers (1)

mankers
mankers

Reputation: 752

The same id (id="newsitesyes") for both inputs might be the problem.

Upvotes: 5

Related Questions