Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/angular/lifecycle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Because of this special handling, the `ngOnInit` and `ngOnDestroy` methods might

`ngOnInit` will only fire each time the page is freshly created, but not when navigated back to the page. For instance, navigating between each page in a tabs interface will only call each page's `ngOnInit` method once, but not on subsequent visits. `ngOnDestroy` will only fire when a page "popped".

Navigating forward to a page that is already in the stack works the same way. Ionic returns to the existing page instead of creating a new one, and pops the pages above it. For instance, navigating from `/login` to `/home` and then forward to `/login` again reuses the original login page, so its `ngOnInit` does not fire a second time. Use `ionViewWillEnter` or `ionViewDidEnter` for logic that needs to run on every visit, such as loading data.

## Route Guards {/* #route-guards */}

In Ionic 3, there were a couple of additional life cycle methods that were useful to control when a page could be entered (`ionViewCanEnter`) and left (`ionViewCanLeave`). These could be used to protect pages from unauthorized users and to keep a user on a page when you don't want them to leave (like during a form fill).
Expand Down
Loading