Skip to content

Commit

Permalink
Modify PageModule and Add routerChild in pages.router.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
atrodriguez88 committed Feb 6, 2018
1 parent 9261d5f commit b8bce27
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 21 deletions.
3 changes: 0 additions & 3 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';
import { RegisterComponent } from './login/register.component';
import { HeaderComponent } from './shared/header/header.component';
import { SidebarComponent } from './shared/sidebar/sidebar.component';
import { BreadcrumbComponent } from './shared/breadcrumb/breadcrumb.component';

// Router
import { AppRoutingModule } from './app.router';
Expand Down
32 changes: 16 additions & 16 deletions src/app/app.router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { PagesComponent } from './pages/pages.component';
Expand All @@ -10,23 +9,24 @@ import { LoginComponent } from './login/login.component';
import { RegisterComponent } from './login/register.component';

const routes: Routes = [
{
path: '',
component: PagesComponent,
children: [
{ path: 'dashboard', component: DashboardComponent },
{ path: 'progress', component: ProgressComponent },
{ path: 'graficas1', component: Graficas1Component },
{ path: '', pathMatch: 'full', redirectTo: 'dashboard' },
]
},
// {
// path: '',
// component: PagesComponent,
// children: [
// { path: 'dashboard', component: DashboardComponent },
// { path: 'progress', component: ProgressComponent },
// { path: 'graficas1', component: Graficas1Component },
// { path: '', pathMatch: 'full', redirectTo: 'dashboard' },
// ]
// },
{ path: 'login', component: LoginComponent },
{ path: 'register', component: RegisterComponent },
{ path: '**', pathMatch: 'full', component: NoPageFoundComponent}
];

@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: true })],
exports: [RouterModule]
})
export class AppRoutingModule { }
// @NgModule({
// imports: [RouterModule.forRoot(routes, { useHash: true })],
// exports: [RouterModule]
// })
// export class AppRoutingModule { }
export const AppRoutingModule = RouterModule.forRoot(routes, { useHash: true });
2 changes: 1 addition & 1 deletion src/app/pages/pages.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<app-breadcrumb></app-breadcrumb>

<!-- <router-outlet></router-outlet> -->
<router-outlet></router-outlet>

<!-- ============================================================== -->
<!-- Start Page Content -->
Expand Down
5 changes: 4 additions & 1 deletion src/app/pages/pages.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { Graficas1Component } from './graficas1/graficas1.component';
import { ProgressComponent } from './progress/progress.component';
import { NoPageFoundComponent } from './no-page-found/no-page-found.component';

import { PagesRoutingModule } from './pages.router';


@NgModule({
declarations: [
Expand All @@ -18,7 +20,8 @@ import { NoPageFoundComponent } from './no-page-found/no-page-found.component';
NoPageFoundComponent
],
imports: [
SharedModule
SharedModule,
PagesRoutingModule
],
exports: [
PagesComponent,
Expand Down
28 changes: 28 additions & 0 deletions src/app/pages/pages.router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { NgModule } from '@angular/core/src/metadata/ng_module';
import { RouterModule, Routes } from '@angular/router';

import { PagesComponent } from './pages.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { ProgressComponent } from './progress/progress.component';
import { Graficas1Component } from './graficas1/graficas1.component';

const routes: Routes = [
{
path: '',
component: PagesComponent,
children: [
{ path: 'dashboard', component: DashboardComponent },
{ path: 'progress', component: ProgressComponent },
{ path: 'graficas1', component: Graficas1Component },
{ path: '', pathMatch: 'full', redirectTo: 'dashboard' },
]
}
];

// @NgModule({
// imports: [RouterModule.forChild(routes)],
// exports: [RouterModule]
// })
// export class PagesRoutingModule { }

export const PagesRoutingModule = RouterModule.forChild(routes);

0 comments on commit b8bce27

Please sign in to comment.