Ionic 4 page does not load record listing update after any change

Asked

Viewed 204 times

-3

Next people, I have two components in Ionic, one that lists users and another that shows the details for modification. All navigation in my app is done through routes. It turns out that after I add a new record, or change an existing one, or even delete a record, I am directed back to the user listing page using the this.router.navigate(['/list']);, there is no automatic updating of the information on the /list page, only the new record appears through inclusion, modification or removal if I update the /list page with F5 (tests performed in the notebook browser).

Is there any way to resolve this in Ionic 4? I would like that when the route is re-directed to the listing page using the this.router.navigate(['/list']); or another method, already include the updated data in the /list, remembering that I use a page for listing /list and another page of record details. /Detail-users.

  • Could you give more info colleague? Are we advinhos now? -1

  • Hehehe was bad @Maurydeveloper, I’ll rephrase the question

1 answer

0


Worked out here guys.

Just use the ionViewWillEnter event.

The ionViewWillEnter event is triggered by entering a page before becoming active. Use it for tasks you want to do every time you enter the view (setting event listeners, updating a table, etc.).

So was my code that calls the users get on the page:

 ngOnInit() {
    //this.getUsers(); antes eu tava chamando o método aqui
  }

  async ionViewWillEnter() { //Foi só eu trocar o nome do método para ionViewWillEnter.
    await this.api.getUser()
      .subscribe(res => {
        console.log(res);
        this.users = res;
      }, err => {
        console.log(err);
      });
  } 

Browser other questions tagged

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