-
Notifications
You must be signed in to change notification settings - Fork 3.2k
docs(react,angular): use ionPage prop for nested outlets and add navigation playgrounds #4454
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2b442d1
docs(react-router): working on v9 migration docs for react router
ShaneK 8fcf1cf
docs(react-router): update navigation guide and expand v5-to-v6 migra…
ShaneK bcf73fe
chore(lint): running lint
ShaneK 12981ad
fix(build): fixing build error
ShaneK 1bd69b1
docs(react-router): fixing several issues
ShaneK d0f6f2f
docs(react-router): converting playground example to rr6
ShaneK 76552ed
docs(react-router): updating dependencies, reverting phrasing change
ShaneK d2401a0
docs(react): fix nested IonRouterOutlet examples and replace live exa…
ShaneK 5228288
fix(docs): use playground component for angular navigation
ShaneK 30ac7db
merge
ShaneK 686435b
chore(lint): running lint
ShaneK 12e3f60
fix(angular): add missing RouterLink import to dashboard component
ShaneK 58873e4
refactor: consolidate angular/react navigation playgrounds into singl…
ShaneK de72886
feat(playground): add default framework setting, migration angular/re…
ShaneK 75c1dc0
chore(git): merge
ShaneK 91f7811
fix(playground): allow playground swapping with default framework set
ShaneK 785d345
docs(navigation): combine playground code to one index file
brandyscarney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ```html | ||
| <ion-app> | ||
| <ion-router-outlet></ion-router-outlet> | ||
| </ion-app> | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ```ts | ||
| import { Component } from '@angular/core'; | ||
| import { IonApp, IonRouterOutlet } from '@ionic/angular/standalone'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-root', | ||
| templateUrl: 'app.component.html', | ||
| imports: [IonApp, IonRouterOutlet], | ||
| }) | ||
| export class AppComponent {} | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| ```ts | ||
| import { Routes } from '@angular/router'; | ||
| import { ExampleComponent } from './example.component'; | ||
|
|
||
| export const routes: Routes = [ | ||
| { | ||
| path: 'example', | ||
| component: ExampleComponent, | ||
| children: [ | ||
| { | ||
| path: 'dashboard', | ||
| loadComponent: () => import('./dashboard/dashboard-page.component').then((m) => m.DashboardPageComponent), | ||
| }, | ||
| { | ||
| path: 'dashboard/:id', | ||
| loadComponent: () => import('./item-detail/item-detail-page.component').then((m) => m.ItemDetailPageComponent), | ||
| }, | ||
| { | ||
| path: 'settings', | ||
| loadComponent: () => import('./settings/settings-page.component').then((m) => m.SettingsPageComponent), | ||
| }, | ||
| { | ||
| path: '', | ||
| redirectTo: '/example/dashboard', | ||
| pathMatch: 'full', | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| path: '', | ||
| redirectTo: '/example/dashboard', | ||
| pathMatch: 'full', | ||
| }, | ||
| ]; | ||
| ``` |
16 changes: 16 additions & 0 deletions
16
static/usage/v9/navigation/angular/dashboard_page_component_html.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| ```html | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Dashboard</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content> | ||
| <ion-list> | ||
| @for (item of items; track item.id) { | ||
| <ion-item [routerLink]="['/example/dashboard', item.id]"> | ||
| <ion-label>{{ item.name }}</ion-label> | ||
| </ion-item> | ||
| } | ||
| </ion-list> | ||
| </ion-content> | ||
| ``` |
27 changes: 27 additions & 0 deletions
27
static/usage/v9/navigation/angular/dashboard_page_component_ts.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| ```ts | ||
| import { Component } from '@angular/core'; | ||
| import { RouterLink } from '@angular/router'; | ||
| import { | ||
brandyscarney marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| IonContent, | ||
| IonHeader, | ||
| IonItem, | ||
| IonLabel, | ||
| IonList, | ||
| IonTitle, | ||
| IonToolbar, | ||
| IonRouterLink, | ||
| } from '@ionic/angular/standalone'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-dashboard-page', | ||
| templateUrl: 'dashboard-page.component.html', | ||
| imports: [IonContent, IonHeader, IonItem, IonLabel, IonList, IonTitle, IonToolbar, IonRouterLink, RouterLink], | ||
| }) | ||
| export class DashboardPageComponent { | ||
| items = [ | ||
| { id: '1', name: 'Item One' }, | ||
| { id: '2', name: 'Item Two' }, | ||
| { id: '3', name: 'Item Three' }, | ||
| ]; | ||
| } | ||
| ``` | ||
14 changes: 14 additions & 0 deletions
14
static/usage/v9/navigation/angular/example_component_html.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| ```html | ||
| <ion-tabs> | ||
| <ion-tab-bar slot="bottom"> | ||
| <ion-tab-button tab="dashboard" href="/example/dashboard"> | ||
| <ion-icon name="grid-outline"></ion-icon> | ||
| <ion-label>Dashboard</ion-label> | ||
| </ion-tab-button> | ||
| <ion-tab-button tab="settings" href="/example/settings"> | ||
| <ion-icon name="settings-outline"></ion-icon> | ||
| <ion-label>Settings</ion-label> | ||
| </ion-tab-button> | ||
| </ion-tab-bar> | ||
| </ion-tabs> | ||
| ``` |
17 changes: 17 additions & 0 deletions
17
static/usage/v9/navigation/angular/example_component_ts.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| ```ts | ||
| import { Component } from '@angular/core'; | ||
| import { IonIcon, IonLabel, IonTabBar, IonTabButton, IonTabs } from '@ionic/angular/standalone'; | ||
| import { addIcons } from 'ionicons'; | ||
| import { gridOutline, settingsOutline } from 'ionicons/icons'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-example', | ||
| templateUrl: 'example.component.html', | ||
| imports: [IonIcon, IonLabel, IonTabBar, IonTabButton, IonTabs], | ||
| }) | ||
| export class ExampleComponent { | ||
| constructor() { | ||
| addIcons({ gridOutline, settingsOutline }); | ||
| } | ||
| } | ||
| ``` |
11 changes: 11 additions & 0 deletions
11
static/usage/v9/navigation/angular/item_detail_page_component_html.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ```html | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-buttons slot="start"> | ||
| <ion-back-button defaultHref="/example/dashboard"></ion-back-button> | ||
| </ion-buttons> | ||
| <ion-title>Item {{ id }}</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding">You navigated to item {{ id }}.</ion-content> | ||
| ``` |
20 changes: 20 additions & 0 deletions
20
static/usage/v9/navigation/angular/item_detail_page_component_ts.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| ```ts | ||
| import { Component, OnInit } from '@angular/core'; | ||
| import { ActivatedRoute } from '@angular/router'; | ||
| import { IonBackButton, IonButtons, IonContent, IonHeader, IonTitle, IonToolbar } from '@ionic/angular/standalone'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-item-detail-page', | ||
| templateUrl: 'item-detail-page.component.html', | ||
| imports: [IonBackButton, IonButtons, IonContent, IonHeader, IonTitle, IonToolbar], | ||
| }) | ||
| export class ItemDetailPageComponent implements OnInit { | ||
| id = ''; | ||
|
|
||
| constructor(private route: ActivatedRoute) {} | ||
|
|
||
| ngOnInit() { | ||
| this.id = this.route.snapshot.paramMap.get('id') ?? ''; | ||
| } | ||
| } | ||
| ``` |
8 changes: 8 additions & 0 deletions
8
static/usage/v9/navigation/angular/settings_page_component_html.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ```html | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Settings</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding">Settings content</ion-content> | ||
| ``` |
11 changes: 11 additions & 0 deletions
11
static/usage/v9/navigation/angular/settings_page_component_ts.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ```ts | ||
| import { Component } from '@angular/core'; | ||
| import { IonContent, IonHeader, IonTitle, IonToolbar } from '@ionic/angular/standalone'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-settings-page', | ||
| templateUrl: 'settings-page.component.html', | ||
| imports: [IonContent, IonHeader, IonTitle, IonToolbar], | ||
| }) | ||
| export class SettingsPageComponent {} | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why
ionPageis now required. We have never recommended adding this as a property and it is not added to any of the playgrounds.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's never been recommended because the docs have been known to be wrongly recommending wrapping IonRouterOutlet in IonPages for several years and nobody has fixed it (note the age of the issue this resolves).
Using the ionPage prop on the router outlet directly benefits mostly nested routes (it's required by them, technically). When you have an outlet containing routes and one of those routes renders another outlet, like in a tab layout, the inner outlet needs to know about and be able to participate in the outer outlet's page transitions. Setting the prop makes the inner outlet itself the animatable page element, so the outer StackManager can transition it properly.
It's generally best to do this everywhere so you don't have to remember to do it in the special nested routing edge cases, and that will also be the case in RR6.