I am working on my Angular4 app and I have a component that uses a *ngFor directive to iterate over an array:
<div *ngFor="let person of persons">
{{person.name}}
{{person.car}}
</div>
Within the same component, there is a feature to delete a car. After successfully deleting a car using the deleteCar()
method, I update the persons
array as follows:
deleteCar(car) {
this.carService.deleteCar(car).subscribe(() => {
this.persons.filter(obj => obj.car == car.name)
.forEach(i => i.car = null);
}
}
The issue I'm facing is that the *ngFor loop does not get triggered when I make changes to an existing person object in the persons array. How can I fix this problem?