ionic-team / ionic-team/ionic-docs

How to run code when a component or page is loaded

Đang mở
#1,893 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
content
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

Mô tả

_Original issue by @ari62 on [2021-04-12T23:59:47Z](https://github.com/ionic-team/ionic-framework/issues/23184)_

# Documentation

Using ionic navigation and ngOnInit won't get fired, as described here :
https://ionicframework.com/docs/angular/lifecycle
However when refreshing the page (browser reload) ionViewDidEnter/ionViewWillEnter don't get fired for components but they seem to be getting fired for Pages along with ngOnInit.

The documentation says
"ngOnInit - Initialize your component and load data from services that don't need refreshing on each subsequent visit."
However why wouldn't someone want their data refreshed on a browser reload for components? This leads us to putting the same code in ngOnInit and ionViewWillEnter, which gets called twice for pages on refresh.

There should be a single place where code can be put to take care of both refreshes and navigation without having to worry about it getting called twice or not at all, or the documentation should be improved to specify how to remove ionic based navigation.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.