Estou acompanhando as aulas de Angular 2, e na parte de rotas lazy (carregamento por demanda) estou com problemas para carregar a página de registro (signup). Aparentemente o router está apagando a parte do caminho quando deveria concatenar com a home.
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PhotosFormComponent } from './photos/photos-form/photos-form.component';
import { PhotosListComponent } from './photos/photos-list/photos-list.component';
import { NotFoundComponent } from './errors/not-found/not-found.component';
import { PhotoListResolver } from './photos/photos-list/photo-list.resolver';
import { CanActivate } from '@angular/router/src/utils/preactivation';
const routes: Routes = [
{
path:'',
pathMatch: 'full',
redirectTo: 'home'
},
{
path: 'home',
loadChildren:'./home/home.module#HomeModule'
},
{path: 'users/:username', component: PhotosListComponent, resolve: {photos: PhotoListResolver}},
{path: 'p/add', component: PhotosFormComponent},
{path: '**', component: NotFoundComponent}];
@NgModule({
imports: [RouterModule.forRoot(routes, {useHash: true})],
exports: [RouterModule]
})
export class AppRoutingModule{ }
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home.component';
import { AuthGuard } from '../core/auth/auth.guard';
import { SigninComponent } from './signin/signin.component';
import { SignupComponent } from './signup/signup.component';
import { NgModule } from '@angular/core';
const routes: Routes = [
{path: '', component: HomeComponent,
canActivate:[AuthGuard],children:[
{
path:'signup',
component: SignupComponent
},
{
path: '', component: SigninComponent
},
]
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class HomeRoutingModule{ }