@cinoi (Cinoi) posted a new topic, subject "SetPages with NavController". It read:

   Good morning,
    
    I am migrating to Ionic4 and I have a question about the way of navigating between pages.
    
    I am using NavController with goRoot, goForward and goBack.
    
    Now I want to be able to set a stack of opened pages when I select a new route from a Menu. I don´t know how to use something similar to the setPages method that I was using with Ionic 3.
    
    I need to set a new Root page and a children.
    
    I have tried this but is not working:
    
    this.navCtrl.goRoot('/rootPage');  
    this.navCtrl.goForward('/rootPage/children');

So @AaronSterling (Aaron Sterling) replied

    The NavController is gone. My suggestion is that you take a day and build an Angular-only app from your favorite Angular tutorial. The routing for that app will be the same as what you will use in Ionic 4. (Modals and popovers are still special in Ionic 4. Mostly.)

After which, @cinoi (Cinoi) added

    Thanks for you reply.
    
    I was following this tutorial to make the changes needed:
    
    Converting Ionic 3 Push/Pop Navigation to Angular Routing in Ionic 4
    
    It explains how to go forward, backwards or set a new root but what I need is to set a new entire stack of routes.
    
    I don´t know if it is possible using Angular Routes or if I can do it with NavController.
    
    Regards.

Then @AaronSterling (Aaron Sterling) said

    That tutorial warns you that the NavController in Ionic 4 is unstable, might be renamed, have different properties, etc. Nobody knows the answer to your question, maybe not even the devs. If you can avoid using NavController, you should. People have been writing Angular apps for years without it. My advice is still the same as it was in my previous post.

After which, @MichaelMalony (Michael Malony) added

    How do you indicate the “router direction” when using the Angular router? The NavController in the latest beta (as described in the article above) is basically just a wrapper around angular routing but also lets you indicate “direction” (forward, back, root) which Ionic uses to select the appropriate animation.
    
    Since NavController isn't in the latest docs I'm guessing it's going to be removed but that leaves a gap in functionality. You can still indicate direction in your template
    [code] 
        <ion-item [routerDirection]="'root'" [routerLink]="[p.url]">
        
    [/code]
    
    But there is no way to give that direction hint if you need to navigate programmatically.
    
    To the original poster, the NavController.goRoot/Forward/Back are currently working for me. Are you sure you have routes defined that match? Check your browser console, is it spitting out any errors?

So @cinoi (Cinoi) replied

    Good morning,
    
    Angular routes is working okey for me and my routes are well defined in the corresponding routing.ts.  
    My problem is that when I navigate through my menu, navCtrl saves the stack of pages where I have passed. Then using the ion-back-button it goes back page by page until it arrives to my main page.  
    I want to navigate directly to my main page when I click the ion-back-button so I need to have always ‘main/start' as root and then goForward the selected menuOption.
    [code] 
                  this.navCtrl.goRoot('main/start');
                  this.navCtrl.goForward(menuOption);
        
    [/code]
    
    But this code is not working and it keeps saving all the pages visited from the menu in the stack.

After which, @pieterjanDB (Pieterjan Db) added

    Bump. Any updates on this? Ionic 5 in the meantime, still no documentation how to navigate to a page within a stack like main/start… Bit weird imo…
    
    I love ionic and have been using it since v1 but lately I have been thinking about switching just because the docs are not ryankristina@example.org.

After which, @mhartington (Mike Hartington) added

    


{'source': 'discourse', 'url': 'https://forum.ionicframework.com/t/setpages-with-navcontroller/138746', 'title': 'SetPages with NavController', 'views': 1441, 'has_accepted_answer': False, 'word_count': 609, 'like_count': 1, 'reply_count': 5, 'participant_count': 4, 'posts': 8, 'tags': '', 'author': '@cinoi (Cinoi)', 'participants': '@cinoi (Cinoi), @AaronSterling (Aaron Sterling), @MichaelMalony (Michael Malony), @pieterjanDB (Pieterjan Db), @mhartington (Mike Hartington)', 'image_url': [None], 'created_at': '2018-08-17T10:09:37.695Z', 'last_posted_at': '2021-07-19T21:01:22.997Z'}