content: Angular "Exiting the App" example exits from pages nested under ion-tabs
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 82/100
- Issue-Typ
- Dokumentation
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- angular, typescript
- Bereich
- documentation
Rechercherichtung
Lies docs/developing/hardware-back-button.mdx und versioned_docs/version-v8/developing/hardware-back-button.mdx und vergleiche die Angular-Tabs-Beispiele mit dem berichteten Verhalten bei verschachtelten Seiten. Aktualisiere beide Beispiele und den begleitenden Satz zur Abfrage von IonRouterOutlet mit @ViewChild, sodass sie den vorgeschlagenen NavController.pop()-Ablauf verwenden. Die Aufgabe ist abgeschlossen, wenn beide Versionen die Zurück-Navigation in Tab-Stacks erklären und zeigen, bevor die App am Stammverzeichnis beendet wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
URL
https://ionicframework.com/docs/developing/hardware-back-button#exiting-the-app
Issue Description
The Angular examples under "Exiting the App" query the root IonRouterOutlet with @ViewChild and exit when canGoBack() is false. In an app that uses ion-tabs, pages inside a tab are stacked in the tab's own outlet, so the root outlet's stack only ever holds the tabs page and canGoBack() is always false. On a page such as /tabs/home/detail, pressing the hardware back button exits the app instead of going back to /tabs/home.
Measured on @ionic/angular 9.0.9:
| Layout, page | Root outlet canGoBack() |
NavController.pop() resolves |
Example |
|---|---|---|---|
| Flat, one page deep | true | true | stays |
| Flat, root | false | false | exits |
Tabs, /tabs/home/detail |
false | true | exits (wrong) |
Tabs, /tabs/home |
false | false | exits |
NavController.pop() walks from the active outlet up through its parents, so its result is the reliable signal. Suggested replacement for both Angular tabs (import from @ionic/angular/lazy for the modules example):
import { Component, inject } from '@angular/core';
import { NavController, Platform } from '@ionic/angular';
import { App } from '@capacitor/app';
@Component({ ... })
export class AppComponent {
private platform = inject(Platform);
private navCtrl = inject(NavController);
constructor() {
this.platform.backButton.subscribeWithPriority(1, async () => {
const popped = await this.navCtrl.pop();
if (!popped) {
App.exitApp();
}
});
}
}
Priority 1 runs before the built-in navigation handler (priority 0) and after menus and overlays (99 and 100), so it takes over the back navigation itself. The sentence about querying IonRouterOutlet with @ViewChild would need to change with it.
Both docs/developing/hardware-back-button.mdx and versioned_docs/version-v8/developing/hardware-back-button.mdx carry the same example.
Reported in ionic-team/ionic-framework#31598.
- Vorherrschende Sprache
- MDX
- Sterne
- 620
- Forks
- 3.2k
- Ø Merge
- 15 Std. 17 Min.
- Gemergte PRs (30 T.)
- 52
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus ionic-team/ionic-docs
-
content
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
ionic-team/ionic-docs#4802 ·
Maintainer antworten meist innerhalb von 1 Tag
-
content: sheet modal docs should explain how to keep interactive content from dragging the sheetOffencontent
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
ionic-team/ionic-docs#4765 ·
Maintainer antworten meist innerhalb von 1 Tag
-
content
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
ionic-team/ionic-docs#4705 ·
Maintainer antworten meist innerhalb von 1 Tag
-
content package: angular
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 78/100
ionic-team/ionic-docs#4702 ·
Maintainer antworten meist innerhalb von 1 Tag
-
triage
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 80/100
ionic-team/ionic-docs#4546 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in ionic-team/ionic-docs
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
btclib-org/btclib#2835 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Link Checker ReportOffenautomated issue linkchecker report
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
QuantEcon/lecture-python.myst#1098 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
chipsalliance/caliptra-sw#4335 ·
Maintainer antworten meist innerhalb von 1 Tag
-
A-documentation good first issue
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
rust-lang/rust-clippy#17926 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
automated issue report
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 1 Tag