On restaurant.component.ts
I want to delete an item from arrayList and update it after delete. The query is performing delete operation but the list is not getting updated. I'm calling the ngOnInit() method but nothing happens
ngOnInit() {
this.restaurantesService.GetRestaurantes()
.subscribe((restaurantes => {
this.restaurantes = restaurantes;
}))
}
qDeleteRestaurantes(CODIGO: number){
var restaurantes = this.restaurantes;
this.restaurantesService.DeleteRestaurantes(CODIGO)
.subscribe((data) => { if (data.n ==1 ){
for(let i=0;i<restaurantes.length;i++){
if(restaurantes[i].CODIGO == CODIGO){
this.restaurantes.splice(i,1);
this.ngOnInit();
}
}
}})
}