Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70435

Ionic 4 router problem with resolver

$
0
0

@ebeliejinfren wrote:

Hi
i use resolver for navigate to page according to this tutorial

1 - but when i change tabs it reload page. it’s happens when back (back button) from child page to parent page
Example : when go from home tab to profile tab then comeback to home tab it(home tab page) reload again

2 - when from a details page go to profile then go back to details page it’s first go home page then go details page (details page is child of home page tab like below code shown)
in this case the home page tab not shown when going back to details page, i use console log in resolver for showing router

app-routing.module.ts

const routes: Routes = [
  {
    path: 'main',
    component: TabsPage,

    children: [
        {
            path: '',
            loadChildren: '../menu/menu.module#MenuPageModule'
        },
        {
            path: 'home',
            resolve: {
                myVariant: ResolverService
            },
            children: [
                {
                    path: '',
                    loadChildren: '../home/home.module#HomePageModule'
                },
                {
                    path: 'songs',
                    resolve: {
                        myVariant: ResolverService
                    },
                    loadChildren: '../songs/songs.module#SongsPageModule'
                },
                {
                    path: 'songs/:id',
                    resolve: {
                        myVariant: ResolverService
                    },
                    loadChildren: '../details/details.module#DetailsPageModule'
                },
 ]
        },
        {
            path: 'search',
            loadChildren: '../search/search.module#SearchPageModule'
        },
        {
            path: 'profile',
            children: [
                {
                    path: '',
                    loadChildren: '../profile/profile.module#ProfilePageModule'
                },
                {
                    path: 'songlist',
                    loadChildren: '../songlist/songlist.module#SonglistPageModule'
                }

resolver.service.ts

let id = route.paramMap.get('id');
    const segment = route.url[0].path;
    console.log(segment);

    let url;
    if (route.url[1]) {
      url = 'app/' + segment + '/' + id
    }else {
      url = 'app/' + segment
    }
    this.api.presentLoading();
    return this.api.getDataApp(url)
    .pipe(
      tap(()=>{
        this.api.dismissLoding();
      }, error=>{
        if (error.name == 'HttpErrorResponse') {
          setTimeout( () => {
            this.api.dismissLoding();
          this.api.presentToast('Please Check Your Conecction !');
          }, 2000);
          
        }
      })
    );
  }

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70435

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>