Table does not reload after deleting a row

Asked

Viewed 88 times

0

Whoa, whoa, whoa, whoa, whoa, whoa, whoa, whoa, whoa, whoa, whoa, whoa, whoa, whoa, whoa, whoa? next, I’m doing a crud for the company where I work, but I’m not able to make it update automatically after I delete the line, being necessary I refresh manually in the browser, I ran a alert(); in function reloadTable() just to test and see if it really was working and yes it is, Alert appears but still it does not perform the operation.. what can I have wrong there? I’m still starting with Angular. Follow my code below:

 delete(row){
    console.log(row);
    this.cartService.delete(row.Id)
    .then(data => this.reloadTable(true));
  }

  reloadTable(reload: boolean = false){
    alert("test");
    this.router.navigate(['../../'], { relativeTo: this.route, queryParams: { reload } });
  }
  • The angular itself is already busy updating the table when you delete a row. However, apparently you are only deleting the line in the backend. An option is in the "reloadTable" function you search in the backend the updated values after deletion. Another option is in "delete(Row)" you remove the value of the variable that is shown in the table as well

  • The list of where you will remove is in the same?

  • @adventistaam yes she is in the same

  • @brenodiogo in the case as I would to fetch this data in the backend using the angular?

  • Look I tried using the this.router.navigate(['../../'], { relativeTo: this.route, queryParams: { reload } }); and I passed the navigate the route to the table link it even atulizes, but only the last line and from time to time still

1 answer

1


I used a function that I had not seen that I already had in my code, my team partner helped me. I used the following solution:

async getAll() {
    this.rows$ = await this.cartService.getAll().toPromise();
  }

  delete(row){
    console.log(row);
    this.cartService.delete(row.Id)
    .then(data => this.getAll());
  }

I erased the function reloadTable() since there was no need to use it and I used the getAll() where she pulls the rows from the table. Now it’s all right, thank you all! <3

Browser other questions tagged

You are not signed in. Login or sign up in order to post.