question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tabs pages with implemented OnInit executed once

See original GitHub issue

Bug Report

Ionic version:

[x] 4.0.0

Current behavior:

As is the title OnInit is only executed once. Maybe it’s related to the outlet but it is annoying because every other pages behave differently.

Expected behavior:

I would love to see the same behaviour on every pages - regardless of whether it is.

Steps to reproduce:

  • two pages in tabs with implemented OnInit
  • try at least to execute console.log

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.9.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.0
   @angular-devkit/build-angular : 0.12.3
   @angular-devkit/schematics    : 7.2.3
   @angular/cli                  : 7.2.3
   @ionic/angular-toolkit        : 1.2.2

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.2, (and 6 other plugins)

System:

   ios-deploy : 1.9.4
   ios-sim    : 7.0.0
   NodeJS     : v10.15.0 (/usr/local/bin/node)
   npm        : 6.4.1
   OS         : macOS Mojave
   Xcode      : Xcode 10.1 Build version 10B61

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rafalschmidt97commented, Feb 18, 2019

@liamdebeasi - yeah I know about them. But I don’t like an idea of keeping logic outside of component where it’s not related to him. It’s just a container for other routes (I think). I understand that this was a choice which you did as a developers (maybe tradeoff?). I hope you get my point of view that all other pages behave differently (they are not cached and OnInit works perfectly).

There are just my thoughts 🚀 Thanks for a discussion and your time. We can close this thread 😇

1reaction
liamdebeasicommented, Feb 6, 2019

Hi @rafalschmidt97,

Thanks for opening an issue with us! Would you be able to clarify the issue you are experiencing? Additionally, can you create a repository that has the code required to reproduce this issue?

Thanks for using Ionic!

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - How to avoid service call more than once when ...
The oninit call should only fire once per component unless they're being destroyed between switching tabs in which case I'd be curious how...
Read more >
Angular Page Component Life Cycle - Ionic Framework
ngOnInit, Fired once during component initialization. This event can be used to initialize local members and make calls into services that only need...
Read more >
OnInit - Angular
A lifecycle hook that is called after Angular has initialized all data-bound ... Define an ngOnInit() method to handle any additional initialization tasks....
Read more >
Lifecycle hooks in Angular 1.5 - Ultimate Courses
tab ); }; } }; var tabs = { transclude: true, controller: function () { this.$onInit = function () { this.tabs = ...
Read more >
3 Common Rxjs Pitfalls (and how to avoid them)
And there we have it, the Save functionality is implemented. ... entirely different, as defining a function does not execute its code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found