diff --git a/core/src/components/router/utils/dom.ts b/core/src/components/router/utils/dom.ts index 449e603b55..b480619021 100644 --- a/core/src/components/router/utils/dom.ts +++ b/core/src/components/router/utils/dom.ts @@ -58,7 +58,16 @@ export function readNavState(root: HTMLElement | undefined) { return {ids, outlet}; } -const QUERY = ':not([no-router]) ion-nav,:not([no-router]) ion-tabs, :not([no-router]) ion-router-outlet'; +export function waitUntilNavNode(win: Window) { + if (searchNavNode(win.document.body)) { + return Promise.resolve(); + } + return new Promise((resolve) => { + win.addEventListener('ionNavWillLoad', resolve, { once: true }); + }); +} + +const QUERY = ':not([no-router]) ion-nav, :not([no-router]) ion-tabs, :not([no-router]) ion-router-outlet'; function searchNavNode(root: HTMLElement|undefined): NavOutletElement|null { if (!root) { diff --git a/core/src/components/router/utils/path.ts b/core/src/components/router/utils/path.ts index eacebeb0b2..eb2339fd76 100644 --- a/core/src/components/router/utils/path.ts +++ b/core/src/components/router/utils/path.ts @@ -26,10 +26,12 @@ export function chainToPath(chain: RouteChain): string[]|null { return path; } -export function writePath(history: History, base: string, usePath: boolean, path: string[], direction: RouterDirection, state: number) { - path = [base, ...path]; - let url = generatePath(path); - if (usePath) { +export function writePath(history: History, root: string, useHash: boolean, path: string[], direction: RouterDirection, state: number) { + let url = generatePath([ + ...parsePath(root), + ...path + ]); + if (useHash) { url = '#' + url; } if (direction === RouterDirection.Forward) {