I have a list of items to display and alongside each item there is a checkbox. I have a condition statement to check whether each item's checkbox should be disabled or enabled. For some unclear reason every checkbox in my list is disabled and i am not sure if it is how i set up the [attr.disabled] or an error in my condition statement.
Here is my html:
<input class="form-control" [attr.disabled]="disabled == true ? true : null"
type="checkbox"[checked]="item.status" (click)="itemChecked($event, item)" />
In my component:
private disabled: boolean;
for( let item of items){
if (item.id == Status.required) {
item.status = true;
this.disabled= true;
} else if (item.id != Status.required && item.list.length > 0) {
item.status = item.id == Status.checked
this.disabled= false;
} else {
item.status = item.id == Status.unchecked;
this.disabled= false;
}
}
Currently in my list regardless of the status of my item, all check boxes are disabled and not sure why.
Aucun commentaire:
Enregistrer un commentaire