[英]ngOnInit and Constructor not called while navigated from previous page using router.navigate
在ionic 4框架中,我已使用router.navigate導航到該頁面。 在導航的頁面中,構造函數和ngOnInit不會從第二次調用。 第一次才打電話。
ngOnInit()在組件初始化期間觸發一次。我認為您的頁面是一個子組件。子組件僅在其父組件被破壞時才會被破壞。這就是構造函數和ngOninit不第二次調用的原因。除了Angular生命周期事件外,Ionic Angular還提供了一些其他事件,您可以使用
ionViewWillEnter() - Fired when the component routing to is about to animate into view.
ionViewDidEnter() - Fired when the component routing to has finished animating.
ionViewWillLeave() - Fired when the component routing from is about to animate.
ionViewDidLeave() - Fired when the component routing to has finished animating.
有關更多詳細信息: -https : //ionicframework.com/docs/angular/lifecycle
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.