mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
fix(router): fix reuse strategy
This commit is contained in:
@ -1,14 +1,17 @@
|
|||||||
import { ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy } from '@angular/router';
|
import {
|
||||||
|
ActivatedRouteSnapshot,
|
||||||
|
DetachedRouteHandle,
|
||||||
|
RouteReuseStrategy
|
||||||
|
} from '@angular/router';
|
||||||
import { deepEqual, objectValues } from './util';
|
import { deepEqual, objectValues } from './util';
|
||||||
|
|
||||||
export class IonicRouteStrategy implements RouteReuseStrategy {
|
export class IonicRouteStrategy implements RouteReuseStrategy {
|
||||||
|
|
||||||
shouldDetach(_route: ActivatedRouteSnapshot): boolean {
|
shouldDetach(_route: ActivatedRouteSnapshot): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// tslint:disable-next-line
|
// tslint:disable-next-line
|
||||||
store(_route: ActivatedRouteSnapshot, _detachedTree: DetachedRouteHandle): void { }
|
store(_route: ActivatedRouteSnapshot, _detachedTree: DetachedRouteHandle): void {}
|
||||||
|
|
||||||
shouldAttach(_route: ActivatedRouteSnapshot): boolean {
|
shouldAttach(_route: ActivatedRouteSnapshot): boolean {
|
||||||
return false;
|
return false;
|
||||||
@ -18,14 +21,25 @@ export class IonicRouteStrategy implements RouteReuseStrategy {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {
|
shouldReuseRoute(
|
||||||
|
future: ActivatedRouteSnapshot,
|
||||||
|
curr: ActivatedRouteSnapshot
|
||||||
|
): boolean {
|
||||||
// checking router params
|
// checking router params
|
||||||
const futureParams = objectValues(future.params);
|
const futureParams = objectValues(future.params);
|
||||||
const currParams = objectValues(curr.params);
|
const currParams = objectValues(curr.params);
|
||||||
|
|
||||||
if (futureParams && !!futureParams.length && currParams && currParams.length > 0) {
|
if (
|
||||||
|
futureParams &&
|
||||||
|
!!futureParams.length &&
|
||||||
|
currParams &&
|
||||||
|
currParams.length > 0
|
||||||
|
) {
|
||||||
// If the router params do not match, render the new component
|
// If the router params do not match, render the new component
|
||||||
return deepEqual(future.params, curr.params);
|
return (
|
||||||
|
deepEqual(future.params, curr.params) &&
|
||||||
|
future.routeConfig === curr.routeConfig
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return future.routeConfig === curr.routeConfig;
|
return future.routeConfig === curr.routeConfig;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user