I encountered an issue with the following code:
...
export class ListCustomersComponent implements OnInit {
customers: Array<Customer> = [];
showCustomer?: Customer;
isSelected: boolean = false;
deletedCustomer?: Customer;
returnedMessage?: string;
constructor(private customerService: CustomerService,
private messageService: MessageService) { }
updateCustomer() {
this.customerService.updateCustomer(this.showCustomer!)
.subscribe((message: Message) => {
console.log(message);
// update customers list
this.customers.map(x => {
if(x.id == this.showCustomer!.id){
ISSUE------> x = this.showCustomer;
}
});
}
The problem lies in the updateCustomer() function at the line x = this.showCustomer;. How can I resolve this error? Thank you for your help.