Last active
November 28, 2017 14:35
-
-
Save gilbertmpanga12/dcb04825f991cdc2ede90297cea9d357 to your computer and use it in GitHub Desktop.
ISSUE WITH ANGULAR ROUTER. Gist is about a problem am facing with angular router, I used lazily loaded routes but when the app loads some of the links dont load as i randomly navigate . What could be the issue?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
In my main app.routing.ts | |
*/ | |
import {Routes} from '@angular/router'; | |
import {AdminLayoutComponent} from './layouts/admin/admin-layout.component'; | |
import {AuthLayoutComponent} from './layouts/auth/auth-layout.component'; | |
import {AuthGuard} from "./welcome/AuthGuard"; | |
import {HelpComponent} from "./help/help.component"; | |
import {HelpSidebarComponent} from "./help/help-sidebar/help-sidebar.component"; | |
import {facilityLayoutComponent} from "./scopes/facilityAccount/facilityLayout.component"; | |
export const AppRoutes: Routes = [ | |
{ | |
path: '', | |
redirectTo: 'dashboard', | |
pathMatch: 'full', | |
}, | |
{ | |
path: '', | |
component: AdminLayoutComponent, | |
canActivate: [AuthGuard], | |
children: [ { | |
path: '', | |
loadChildren: './dashboard/dashboard.module#DashboardModule' | |
}, | |
{ | |
path: 'components', | |
loadChildren: './components/components.module#ComponentModule', | |
} | |
], | |
}, | |
{ | |
path: 'facilityAccount', | |
component: facilityLayoutComponent, | |
children: [{ | |
path: '', | |
loadChildren: './scopes/facilityAccount/facility-account.module#FacilityAccountModule' | |
} | |
] | |
}, | |
{ | |
path: 'help', | |
loadChildren: './help/help.module#HelpModule' | |
}, | |
{ | |
path: '', | |
component: AuthLayoutComponent, | |
children: [{ | |
path: '', | |
loadChildren: './welcome/welcome.module#WelcomeModule' | |
} | |
] | |
} | |
]; | |
/* | |
In components.routing.ts | |
*/ | |
import {Routes} from "@angular/router"; | |
import {DepositComponent,ExtraPaymentComponent, | |
LoansComponent,PaybillComponent,SettingsComponent,TransferFundsComponent, | |
FacilityOneComponent,FacilityTwoComponent,HistoryComponent | |
} from "./index"; | |
export const COMPONENTROUTES:Routes = [ | |
{ | |
path: '', | |
children: [ { | |
path: 'deposit', | |
component: DepositComponent | |
}]}, | |
{ | |
path: '', | |
children: [ { | |
path: 'paybill', | |
component: PaybillComponent | |
}]}, | |
{ | |
path: '', | |
children: [ { | |
path: 'transfer', | |
component: TransferFundsComponent | |
}]}, | |
{ | |
path: '', | |
children: [ { | |
path: 'loans', | |
component: LoansComponent | |
}]}, | |
{ | |
path: '', | |
children: [ { | |
path: 'facilityone', | |
component: FacilityOneComponent, | |
data:{preload:true} | |
}]}, | |
{ | |
path: '', | |
children: [ { | |
path: 'facilitytwo', | |
component: FacilityTwoComponent | |
}]} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment