I have a dropdown on each line of a table row and every time I select one option from dropdown the selected value is updated with same value on rest dropdowns:
my html code:
<p-table....>
<ng-template pTemplate="body" let-user>
<tr>
current user permission: {{user.Permission}}
<p-dropdown [options]="PermissionOptions" [(ngModel)]="permissionVal" placeholder="change..." optionLabel="name">
</p-dropdown>
</td>
</tr>
</ng-template>
TS:
interface PermissionType {
name: string,
}
PermissionOptions1: PermissionType[];
permissionVal1: PermissionType;
constructor()
{
this.PermissionOptions1 = [
{name: FolderPermissionEnum.WRITE},
{name: FolderPermissionEnum.READ},
];
}
The problem may be spotted on variable permissionVal that receive the selected value from dropdown, and right now that value is common for all dropdowns on the table. If somehow I can change that variable permissionVal to be an array maybe I could solve the problem but I don't know how I can do it or call it on HTML.