content: Example shows uncommon IonRouterOutlet usage
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 62/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- angular, typescript
- Lĩnh vực
- documentation, mobile-dev
Hướng nghiên cứu
Mở tài liệu được liên kết về nút quay lại phần cứng và kiểm tra tab Angular (Standalone), tập trung vào cách IonRouterOutlet được inject. Cập nhật ví dụ để hiển thị một cách tiếp cận hoạt động được với component cấp cao nhất cho hành vi thoát mặc định theo kiểu Android, sau đó xác minh rằng đoạn mã được hiển thị khớp với trường hợp sử dụng đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
URL
https://ionicframework.com/docs/developing/hardware-back-button#exiting-the-app
Issue Description
On the linked page (I am referencing the Angular (Standalone) tab), the IonRouterOutlet is injected via the constructor.
However, this only works if it used in a subcomponent of the app and not in AppComponent and, I would argue that this is a rather uncommon use-case, as the usual developer probably only wants to add it to the top-most component.
In my case, I had to search for quite some time to find a really neat solution in the following issue comment, and according to the reactions I am not alone (note that the issue is also locked since nearly 4 years!):
https://github.com/ionic-team/ionic-framework/issues/21630#issuecomment-683007162
IMO, the docs example should show a working way of implementing the default behavior (like in native Android apps) in a straightforward way like:
import { ViewChild } from '@angular/core';
import { IonRouterOutlet, Platform } from '@ionic/angular/standalone';
import { App } from "@capacitor/app";
// ...
@ViewChild(IonRouterOutlet, {static: true}) routerOutlet?: IonRouterOutlet
constructor(private platform: Platform) {
this.platform.backButton.subscribeWithPriority(-1, () => {
if (this.routerOutlet && !this.routerOutlet.canGoBack()) {
App.exitApp();
}
});
}
- Ngôn ngữ chính
- MDX
- Star
- 621
- Fork
- 3.2k
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 86
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ionic-team/ionic-docs
-
content
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
ionic-team/ionic-docs#4705 ·
-
content package: angular
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 78/100
ionic-team/ionic-docs#4702 ·
-
triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
ionic-team/ionic-docs#4546 ·
-
content: broken link Đang mởcontent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ionic-team/ionic-docs#4381 · 2 bình luận ·
-
triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
ionic-team/ionic-docs#3639 ·
Tất cả issue của ionic-team/ionic-docs
Issue tương tự
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
user-reported
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Kong/developer.konghq.com#7316 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
HarperFast/skills#96 ·
-
Client support matrix inclusion Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
infinispan/infinispan#18150 ·