So i have a table that is populated by an api, and in this table there is a checkbox and a permission element for each row(i also have a checkbox in the table header that checks/unchecks all other checkboxes).
As the user clicks a checkbox i need to verify their permission, and if their permission isn't admin add the row to a wronPerm
array, otherwise add it to a rightPerm
array, and as the checkboxes get unchecked remove them from the respective arrays.
Could someone help me out? i already tried this a couple of times but performance seems horrible
What i have so far:
someTest(row) {
if (row.role == 'ADMIN') {
if(this.rightPerm.includes(row) == true ){
this.rightPerm.splice(row,1);
}
else{
this.rightPerm.push(row);
}
}
else{
if(this.wrongPerm.includes(row) == true){
this.wrongPerm.splice(row,1);
}
else{
this.wrongPerm.push(row);
}
}
}
And the checkbox in the HTML
<mat-checkbox (change)="someTest(row) ; "
Aucun commentaire:
Enregistrer un commentaire