I have this checkbox
<div *ngFor="let user of userList">
{{ userList.Name }}
<input type="checkbox" (change)="selectUser($event,user)">
</div>
selectUser(event,user)
{
if (event.target.checked) {
const userDetails = {
userID: user.UserID,
Name:Name ,
};
this.tempLists.push(userDetails);
}
else
{
this.tempLists= this.tempLists.filter(function(obj) {
return obj.userID !== user.UserID;
});
}
}
in this method I'm adding the selected user to the array, but i want that if id is present in the array then when reloading the content where checkbox is present, the checkbox should be selected if that particular id is present in the array.