I've created a table where the priority of top 3 rows are set by using radio buttons. Goal is to make the siblings radio buttons enabled/disabled when checked/unchecked. I'm able to get the buttons checked/unchecked vertically by providing the same name on each row but I'm not being able to do that to it's siblings horizontally.
I've tried using ([attr.disabled]="boolean") on input element but that disables all the buttons in the table. I also tried doing it with javascript but it makes the code really long which is still not perfect.
If anyone could help !!
Below is my code.
HTML
<tr *ngFor="let news of newss">
<td>{{ news.newstitle }}</td>
<td>{{ news.newsdescription }}</td>
<td>{{ news.display }}</td>
<td>{{ news.status }}</td>
<td><span> {{ news.photo }}</span></td>
<td>
<div class="radio">
<label><input type="radio" name="priority1" #priority1
(change)="handleChange($event, news, priority1)"
[attr.disabled]="disprior1" /></label>
</div>
<div class="radio">
<label><input type="radio" name="priority2" #priority2
(change)="handleChange($event, news, priority2)"
[attr.disabled]="disprior2" /></label>
</div>
<div class="radio">
<label><input type="radio" name="priority3" #priority3
(change)="handleChange($event, news, priority3)"
[attr.disabled]="disprior3" /></label>
</div>
</td>
</tr>
TS:
handleChange(evt, news, priority) {
let target = evt.target;
if (target.checked) {
if (priority.name == "priority1") {
this.disprior2 = true;
this.disprior3 = true;
} else if (priority.name == "priority2") {
this.disprior1 = true;
this.disprior3 = true;
} else if (priority.name == "priority3") {
this.disprior1 = true;
this.disprior2 = true;
}
}
}
