I need to update an HTML table after updating my values. On Ionic (based on Angular) all was working fine when I was calling my datas loading function. But in Angular, whenever I call my data loading function, the array isn't updated..
I've already tried to deal with ChangeDetectorRef but nothing works...
Here are my functions :
loadCat() {
this.apiService.listCat().then(data => {
this.categories = data;
});
this.ref.detectChanges();
}
addCat() {
this.apiService.createAssoc(this.label);
this.assoForm.reset();
this.loadAssoc();
}
deleteCat(id) {
this.apiService.deleteCat(id);
this.notify.fireSuccess("La catégorie a bien été supprimée !", "Bye bye !");
this.loadCat();
}
And here is a part of HTML table code :
<tbody>
<tr *ngFor="let cat of categories; index as i">
<th scope="row">{{ i+1 }}</th>
<td>{{ cat.label }}</td>
<td><button (click)="deleteCat(cat._id)" class="btn btn-danger">Supprimer</button></td>
</tr>
</tbody>
I need by tags to be reload with my new categories values but nothing works...
deleteCat(cat._id)function .categoriesin your template but i can't find where you update this variable in your componentconsole.log(data)insidethen?