ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.01k stars 13.51k forks source link

'onSameUrlNavigation' config doesn't work in v4. #17867

Open anjildhamala opened 5 years ago

anjildhamala commented 5 years ago

Current Ionic Info

Ionic:

ionic (Ionic CLI) : 4.10.3 (/Users/myUser/.nvm/versions/node/v10.15.0/lib/node_modules/ionic) Ionic Framework : @ionic/angular 4.1.2 @angular-devkit/build-angular : 0.13.6 @angular-devkit/schematics : 7.2.4 @angular/cli : 7.3.6 @ionic/angular-toolkit : 1.4.1

System:

NodeJS : v10.15.0 (/Users/myUser/.nvm/versions/node/v10.15.0/bin/node) npm : 6.4.1 OS : macOS Mojave

Current behavior: I'm trying to fetch new data based on a global resolved value when a specific page reloads. My resolver fires fine but the activatedRoute.data doesn't receive new data from resolver.

Expected behavior: Ideally, the data should flow back to activatedRoute.data and I should get the new resolved data when the page reloads. It works fine in a pure Angular project.

Steps to reproduce:

  1. Create new Lazy Loaded Ionic Project with Tabs template.
  2. Head over to tab1 and add a new button which on click performs: this.router.navigate([], {relativeTo: this.activatedRoute});
  3. Set up a subscription in the page to the latest data from the activatedRoute.data stream. this.activatedRoute.data.subscribe(val => {console.log(val)});

Related code: Set onSameUrlNavigation: 'reload' config in RouterModule.forRoot() method. Add a resolver to Tab1 which resolves with an array with a random value.

resolve() {
  return of([Math.random()]);
}

In Tab1Module route variable, add resolve {data: Tab1Resolver}, runGuardsAndResolvers: 'always'

Here's a minimal Ionic Tabs starter template with the essential code where this issue can be observed. github

Here's a Stackblitz working reproduction of a pure Angular application. Product Details Page

Please let me know if I can provide more information to get this issue sorted.

anjildhamala commented 5 years ago

Any updates, guys?

chrisworrell commented 5 years ago

what is the status of this?

niclaforge commented 4 years ago

Any update or workaround for this? This is still an issue in ionic v5