Advertisement
Guest User

Untitled

a guest
Jan 27th, 2017
587
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. App.Module
  2.  
  3. @NgModule({
  4.     imports: [
  5.         BrowserModule,
  6.         FormsModule,
  7.         HttpModule,
  8.         MainModule,
  9.         routing
  10.     ],
  11.     declarations: [
  12.         AppComponent,
  13.         LoginViewComponent
  14.     ],
  15.     bootstrap: [AppComponent]
  16. })
  17.  
  18. Main.Module
  19.  
  20. @NgModule({
  21.     imports: [
  22.         CommonModule,
  23.         FormsModule,
  24.         mainChildRouting
  25.     ],
  26.     declarations: [
  27.         ListViewComponent,
  28.         MainComponent,
  29.         PatientDetailsComponent,
  30.         UnitInfoComponent,
  31.     ],
  32.     providers: [
  33.         DateService
  34.     ]
  35. })
  36.  
  37. App.Routes
  38.  
  39. const routes: Routes = [
  40.     {
  41.         path: 'login',
  42.         component: LoginViewComponent
  43.     },
  44.     {
  45.         path: 'main',
  46.         component: MainComponent
  47.     },
  48.     {
  49.         path: '',
  50.         redirectTo: 'main',
  51.         pathMatch: 'full'
  52.     }
  53. ];
  54.  
  55. const mainChildRoutes: Routes = [
  56.     {
  57.         path: 'main',
  58.         component: MainComponent,
  59.         children:
  60.         [
  61.             {
  62.                 path: '',
  63.                 component: ListViewComponent,
  64.             },
  65.             {
  66.                 path: 'unit_list',
  67.                 component: UnitInfoComponent
  68.             },
  69.             {
  70.                 path: 'unit_info',
  71.                 children:
  72.                 [
  73.                     {
  74.                         path: '',
  75.                         component: PatientListComponent
  76.                     },
  77.                     {
  78.                         path: 'patient',
  79.                         component: PatientDetailsComponent
  80.                     }
  81.                 ]
  82.             },
  83.         ]
  84.     }
  85. ];
  86.  
  87. export const routing: ModuleWithProviders = RouterModule.forRoot(routes, { useHash: true });
  88.  
  89. export const mainChildRouting: ModuleWithProviders = RouterModule.forChild(mainChildRoutes);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement