Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.2k
docs(router): remove ion-nav from coordinated navigation outlets#4585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
575686335944ef7e0063af192b3ebe7d988fb6326bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Router | ion-nav within a Routed Page</title> | ||
| <link rel="stylesheet" href="../../common.css" /> | ||
| <script src="../../common.js"></script> | ||
| <script | ||
| type="module" | ||
| src="https://cdn.jsdelivr.net/npm/@ionic/core@8.8.14-dev.11784216165.1ecbf364/dist/ionic/ionic.esm.js" | ||
| ></script> | ||
| <link | ||
| rel="stylesheet" | ||
| href="https://cdn.jsdelivr.net/npm/@ionic/core@8.8.14-dev.11784216165.1ecbf364/css/ionic.bundle.css" | ||
| /> | ||
| </head> | ||
| <body> | ||
| <ion-app> | ||
| <!-- The router drives URL-based navigation through ion-router-outlet --> | ||
| <ion-router> | ||
| <ion-route url="/" component="page-home"></ion-route> | ||
| <ion-route url="/details" component="page-details"></ion-route> | ||
| </ion-router> | ||
| <ion-router-outlet></ion-router-outlet> | ||
| <script> | ||
| // A routed page: navigating here updates the URL to /details. | ||
| class PageHome extends HTMLElement { | ||
| connectedCallback() { | ||
| this.innerHTML = ` | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Home</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <ion-router-link href="#/details"> | ||
| <ion-button>Go to Details (URL changes)</ion-button> | ||
| </ion-router-link> | ||
| </ion-content>`; | ||
| } | ||
| } | ||
| // This routed page hosts its own ion-nav for a local stack. | ||
| // Pushing and popping within the ion-nav does not change the URL. | ||
| class PageDetails extends HTMLElement { | ||
| connectedCallback() { | ||
| this.innerHTML = `<ion-nav root="details-step-one"></ion-nav>`; | ||
| } | ||
| } | ||
| class DetailsStepOne extends HTMLElement { | ||
| connectedCallback() { | ||
| this.innerHTML = ` | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-buttons slot="start"> | ||
| <ion-back-button default-href="/"></ion-back-button> | ||
| </ion-buttons> | ||
| <ion-title>Details - Step 1</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <ion-nav-link router-direction="forward" component="details-step-two"> | ||
| <ion-button>Next step (URL stays the same)</ion-button> | ||
| </ion-nav-link> | ||
| </ion-content>`; | ||
| } | ||
| } | ||
| class DetailsStepTwo extends HTMLElement { | ||
| connectedCallback() { | ||
| this.innerHTML = ` | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-buttons slot="start"> | ||
| <ion-back-button></ion-back-button> | ||
| </ion-buttons> | ||
| <ion-title>Details - Step 2</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| The URL is still /details. This step is managed by ion-nav, not the router. | ||
| </ion-content>`; | ||
| } | ||
| } | ||
| customElements.define('page-home', PageHome); | ||
| customElements.define('page-details', PageDetails); | ||
| customElements.define('details-step-one', DetailsStepOne); | ||
| customElements.define('details-step-two', DetailsStepTwo); | ||
| </script> | ||
| </ion-app> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import Playground from '@site/src/components/global/Playground'; | ||
| import javascript from './javascript.md'; | ||
| <Playground | ||
| version="9" | ||
| code={{ javascript }} | ||
| src="usage/v9/router/nav-within-page/demo.html" | ||
| devicePreview={true} | ||
| includeIonContent={false} | ||
| /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| ```html | ||
| <!-- The router drives URL-based navigation through ion-router-outlet --> | ||
| <ion-router> | ||
| <ion-route url="/" component="page-home"></ion-route> | ||
| <ion-route url="/details" component="page-details"></ion-route> | ||
| </ion-router> | ||
| <ion-router-outlet></ion-router-outlet> | ||
| <script> | ||
| // A routed page: navigating here updates the URL to /details. | ||
| class PageHome extends HTMLElement { | ||
| connectedCallback() { | ||
| this.innerHTML = ` | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Home</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <ion-router-link href="#/details"> | ||
| <ion-button>Go to Details (URL changes)</ion-button> | ||
| </ion-router-link> | ||
| </ion-content>`; | ||
| } | ||
| } | ||
| // This routed page hosts its own ion-nav for a local stack. | ||
| // Pushing and popping within the ion-nav does not change the URL. | ||
| class PageDetails extends HTMLElement { | ||
| connectedCallback() { | ||
| this.innerHTML = `<ion-nav root="details-step-one"></ion-nav>`; | ||
| } | ||
| } | ||
| class DetailsStepOne extends HTMLElement { | ||
| connectedCallback() { | ||
| this.innerHTML = ` | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-buttons slot="start"> | ||
| <ion-back-button default-href="/"></ion-back-button> | ||
| </ion-buttons> | ||
| <ion-title>Details - Step 1</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <ion-nav-link router-direction="forward" component="details-step-two"> | ||
| <ion-button>Next step (URL stays the same)</ion-button> | ||
| </ion-nav-link> | ||
| </ion-content>`; | ||
| } | ||
| } | ||
| class DetailsStepTwo extends HTMLElement { | ||
| connectedCallback() { | ||
| this.innerHTML = ` | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-buttons slot="start"> | ||
| <ion-back-button></ion-back-button> | ||
| </ion-buttons> | ||
| <ion-title>Details - Step 2</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| The URL is still /details. This step is managed by ion-nav, not the router. | ||
| </ion-content>`; | ||
| } | ||
| } | ||
| customElements.define('page-home', PageHome); | ||
| customElements.define('page-details', PageDetails); | ||
| customElements.define('details-step-one', DetailsStepOne); | ||
| customElements.define('details-step-two', DetailsStepTwo); | ||
| </script> | ||
| ``` |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.