I'm using the Angular 8 and Ionic 4. I have a route for activity which is used for the creating(POST) or editing (PUT) base on onEditMode
param provided in NavigationExtras state
.
However after accessing the route for the second time it shows old outdated data - maybe Angular preserve reloading, but I would like to change so it will work like the Ionic 3 navigation - reload on every page change.
I would like to have an option to remove activities:name
page for navigation stack so I can navigate to that page with new params and update the page view based on that params.
App routing module
{
path: 'activities/:name',
loadChildren: () =>
import('./pages/activities/activities-routing.module').then(m => m.ActivitiesRoutingModule)
}
And navigating function
let navigationExtras: NavigationExtras = {
state: {
date: this.reportDate,
href: this.getCurrentUrlWithoutTabs(this.router.url),
report: data,
editMode: true,
reportData: report,
previewMode: preview
},
replaceUrl: true,
skipLocationChange: true
};
let backHref = 'daily-overview'
this.router.navigateByUrl(`/tabs/activities/${pageUrl}`, navigationExtras)
.then(() => this.router.navigate([`/tabs/activities/${pageUrl}`]))
Gist => app-routing.module.ts https://gist.github.com/Verthon/a9432a502329e6d30b05b1d9db53d9dc
Gist => activity.page.ts https://gist.github.com/Verthon/59a107552b997f517e910b6fa83c03cd
Gist => gotToAcitivity() https://gist.github.com/Verthon/537fe2fb407997aa7e45fa7cb49467bb
this.router.navigate(['daily-overview'], { replaceUrl: true })
andhistory.state
changes to correct one however the page is still outdated. – Verthon