Skip to content

[Ionic V4-beta.12] Bug router-outlet destroyed #15798

Closed

Description

@Anthony2539

Bug Report

Ionic Info

   ionic (Ionic CLI)          : 4.1.2 (C:\Users\ariefolo\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.12
   @angular-devkit/core       : 0.8.3
   @angular-devkit/schematics : 0.8.3
   @angular/cli               : 6.2.3
   @ionic/ng-toolkit          : 1.0.0
   @ionic/schematics-angular  : 1.0.1

Describe the Bug
In my app, i navigate between two pages.
My first page is a list of stations and my second page display details station.
For navigate to details station i use this:

this.router.navigate(['station'], {queryParams: station});

And for go back:

this.location.back();

In my detail page i get the station like this:

let stationObservable = this.route.queryParamMap.pipe(
      switchMap(params => {
        this.station = params["params"];
        console.log("STATION ========> "+this.station.name);
        return this.ginkoService.fetchTempsLieu(this.station.name);
      })
    );
    stationObservable.subscribe((stationAttente) =>{
   
    });

when I navigate several times between the two pages and change stations, sometimes the station does not change while the url has changed. At this moment i can see in the debug console

router-outlet destroyed

Steps to Reproduce
Steps to reproduce the behavior:

  1. Navigate between two pages.
  2. Change station
  3. Sometimes the station doesn't change
  4. Router-outlet destroyed

Additional Context
This is my route:

const routes: Routes = [
  { path: '', loadChildren: './tabs/tabs.module#TabsPageModule', canActivate: [AuthGuard] },
  { path: 'tabs', loadChildren: './tabs/tabs.module#TabsPageModule', canActivate: [AuthGuard] },
  { path: 'station', loadChildren: './pages/station/station.module#StationPageModule', canActivate: [AuthGuard] },
  { path: 'schedule', loadChildren: './pages/schedule/schedule.module#SchedulePageModule', canActivate: [AuthGuard] }
];

Activity

  1. zaarheed commented on Sep 29, 2018

    @zaarheed

    I also have this issue on v4.0.0-beta.11. It occurs only if I go from the initial module that loads for my app to a different module, and then try to navigate to a route from the initial module.

    i.e.

    • App starts and loads Module A, showing Component 1
    • Press a button and be navigated to Module B, showing Component 2
    • Press the back button and come back to Module A Component 1
    • Press a button to be navigated to Module A, Component 3 - but this doesnt work. The URL changes but the screen remains the same.

    Occurs in Chrome when running ionic serve, iOS 12 iPhone X simulator, and iPhone 6S iOS 12 real device.

  2. lapachuka commented on Oct 2, 2018

    @lapachuka

    +1

  3. naveedahmed1 commented on Oct 3, 2018

    @naveedahmed1

    I think Angular Router in Ionic 4 Beta 12 requires a complete review its very unstable. And navigation is the core of any applications so Angular routing should be very robust.

  4. Anthony2539 commented on Oct 13, 2018

    @Anthony2539
    Author

    Any solution for this issue ?

  5. lapachuka commented on Oct 13, 2018

    @lapachuka

    Temporary i'm using <router-outlet> instead of <ion-router-outlet>. Don't know if it would be solution for you .

  6. zaarheed commented on Oct 13, 2018

    @zaarheed

    I temporarily resolved this by creating a StartupModule that is loaded when the app is opened. It shows a loading spinner whilst the user’s location is determined and then it navigates to my original start module.

    This resolves the issue for me, but only really works because I need to determine the user’s location anyway. Perhaps as a temporary work-around you could just show the splash screen in the StartupModule for one second before navigating to the original module.

    I believe you may also be able to use NavController.navigateRoute() to set the original module as the root screen to avoid the user being able to press back and find themselves back at the StartupModule.

  7. Chethannp commented on Oct 22, 2018

    @Chethannp

    Any update on this ??

  8. ddsurf123 commented on Oct 22, 2018

    @ddsurf123

    Same issue, very unstable with multiple routers router-outlet destroyed is contant issue if pulling any data from api. If simple page loads static empty no issues.

  9. jordanpurinton commented on Oct 24, 2018

    @jordanpurinton
    Contributor

    Bump

  10. Franky238 commented on Nov 16, 2018

    @Franky238

    this issue appear if you forgot to close some html tag. for example: ion-header

  11. 5 remaining items

  12. removed
    package: angular
    on Dec 13, 2018
  13. added and removed
    needs: reply
    on Dec 14, 2018
  14. paulstelzer commented on Dec 14, 2018

    @paulstelzer
    Contributor

    @urbanjoe could you plese tell me what I should look at? I am starting it and it's just a title there - no navigation or something like that
    firefox_2018-12-14_13-46-06

  15. urbanjoe commented on Dec 14, 2018

    @urbanjoe

    ups, just swipe from the right.. there is the menu:
    git_screenshot_1

    Reproduce:
    Please start with objects and click 1,2,3
    grafik

    Then click on Task and u get the render-outlet destroyed and the navigation does not work anymore in that outlet
    grafik

  16. paulstelzer commented on Dec 14, 2018

    @paulstelzer
    Contributor

    @urbanjoe Alright: Your issue is because of two things:

    1. You are using two ion-split-panes. Here it's normal that one will be destroyed if you leave the page with it (e.g. with the tasks).

    2. You are using href, please always use routerLink and always absolute paths (this you already did)

    If you doing step 2, it will work okay. For example I changed it for the object lists and then it's looking good (see gif). And if I leave the page, it's normal that router-outlet destroyed arrives because the objects list with the split-pane will be destroyed and so this log occurs

    2018-12-14_13-57-28

    And here you can see that the navigation works perfect afterwards:
    2018-12-14_13-59-54

  17. urbanjoe commented on Dec 14, 2018

    @urbanjoe

    @paulstelzer Yes, u are right, the repo has no update to the beta 18 (routerLink) right now, but locally i already updated.

    Please try to navigate between taks and object (both are childs), the the destroyed appears. If u go to a root page and then to another child page everything is ok :-/

  18. paulstelzer commented on Dec 14, 2018

    @paulstelzer
    Contributor

    @urbanjoe Ah okay, what you now describe is what I already created as seperate issue -> #16411 (there is also a workaround - hopefully this work for you too)

  19. urbanjoe commented on Dec 14, 2018

    @urbanjoe

    Perfect, i'll give it a shoot

  20. paulstelzer commented on Dec 14, 2018

    @paulstelzer
    Contributor

    @urbanjoe Your issue is the same like #16411 - Could you please comment there?

  21. paulstelzer commented on Dec 14, 2018

    @paulstelzer
    Contributor

    I talked with @manucorporat about this topic. So I summarize it here and will close the issue because of the following:

    • "router-outlet destroyed" is not a bug, it's only shows you that the component with <ion-router-outlet> inside is destroying
    • What are the reasons this happening? In general you are using more than one <ion-router-outlet> or using ion-tabs. If a component will be destroyed (removed from the dom - ngOnDestroy() also calls) and there is <ion-router-outlet> inside (or ion-tabs), the "router-outlet destroyed" will be displayed in the console
    • Another reason: You are using different layouts (with sidebar, then a fullscreen layout) and every contains a <ion-router-outlet>. If you now destroy the parent component, "router-outlet destroyed" will be displayed in the console

    But also keep in mind:

    I hope that I described it in detail so everyone knows what happens. And as I said that you get problems, has not to do with the logs, the root cause is something else :)

    And because the root cause is not "router-outlet destroyed", it's better to open a issue for every problem. So if your problem is not #16411 or #15538 or #16736, please make a short search (maybe there is already an issue for) and if not, please create a new issue and include a repo so we can check it!

  22. ionitron-bot commented on Jan 13, 2019

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  23. locked and limited conversation to collaborators on Jan 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions