HTML element don't show values of a provider

Hello community.

I have basically three pages:

1 - Cart (show purchased products)
2 - resume(purchased products and delivery address)
3 - Address (Address List)

On the cart page when I click the finish button, I am directed to the resume page.
The resume page shows the cart items and a label with the address if it has been previously selected. If you have no address selected the label is not shown.
This page also has a button. Clicking the button directs me to the address list page.
When I select the address from the list I am directed back to the resume page.
And now, on the resume page, the selected address should appear on the label, but it’s not appearing.
But if I go back to the cart page and select the finish button again, the address appears on the label.

If when I click the finish button on the cart page and am directed straight to the address list page.
When you select the address and return to the resume page, the address appears on the label.

cart.page.ts

 finish(){
    this.router.navigate(['resume']);
  }

resume.page.ts

  selectAddress() {
    this.router.navigate(['address']);
  }

  ngOnInit() {
    this.address= this.addressService.getAddress();
}

address.page.ts

  selectAddress(address){
    this.addressService.setAddress(address);
    
    this.router.navigateByUrl('resume');
  }

address.service.ts

  getAddress(){
    return this.address;
  }

  setAddress(add){
    this.endereco = add;
  }

This post describes your situation and suggests an approach that you might find useful.

1 Like

I don’t know if it is the best manner, but i solved my problem with this code:

resume.page.ts

    ionViewDidEnter() {
      this.address= this.addressService.getEndereco();
    }