There is a global List
array where data from an API is passed in the OnInit method.
List: any;
visibility:any;
Status:any;
ngOnInit(): void {
let param = {...};
this.Service.getUser(param).subscribe(result => {
this.List = result['response'];
});
}
now creating dynamic checkboxes and dropdowns
<div class="example-box" *ngFor="let user of List;let i = index">
<input type="checkbox" [(ngModel)]="visibility[i]">
{{ user.Name }}
<select name="status" [(ngModel)]="Status[i]">
<option value="1" selected>Active</option>
<option value="0">Inactive</option>
</select>
</div>
The issue arises when trying to update values simultaneously by looping through the main array. How can one fetch the dropdown and checkbox values at each index and save them as follows:
{
"Name": "John",
"visibility": 0,
"IsActive": 1
},
{
"Name": "Peter",
"visibility": 1,
"IsActive": 1
},
...
It's important to note that the cdk
dragdrop feature is being used, requiring a loop through the entire list after sorting. Any suggestions would be greatly appreciated. Thank you!