As I attempt to iterate over this.data.members and perform certain actions within the forEach loop on this.addedUsers, I encounter a TypeError: Cannot read property 'addedUsers' of undefined. Interestingly, I can access this.data.members outside the forEach loop.
export class AddgroupComponent implements OnInit {
public addedUsers: any[] = [];
constructor(
@Inject(MAT_DIALOG_DATA) public data: any
) { }
ngOnInit(): void {
this.data.members.forEach(function (item) {
console.log(this.addedUsers)
});
}
}
}