尝试在角度为6的主模块和延迟加载的模块之间路由

时间:2019-03-06 19:16:55

标签: routing angular6

尝试在主模块和延迟加载的模块之间进行路由
我在router.navigate上附加了一个点击侦听器,它指向太阳路径,但只会刷新页面。没有控制台错误出现。

主模块

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { LoginComponent } from './login/login.component';
import { AuthGuard } from './guards/auth.guard';

const routes: Routes = [
    {path: '', redirectTo: '/dashboard', pathMatch: 'full'},
    {path: 'login', component: LoginComponent},
    {path: 'dashboard', loadChildren: './modules/dashboard/dashboard.module#DashboardModule', canActivate: [AuthGuard]},
    {path: 'request-form', loadChildren: './modules/request-form/request-form.module#RequestFormModule', canActivate: [AuthGuard]},
    {path: 'solar', loadChildren: './modules/solar/solar.module#SolarModule', canActivate: [AuthGuard] }
];

@NgModule({
    imports: [RouterModule.forRoot(routes, {useHash: true})],
    exports: [RouterModule]
})
export class AppRoutingModule { }

辅助模块
没有路由到“太阳能”路径

import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { AuthGuard } from '../../guards/auth.guard';
import { SolarDashboardPageComponent } from './solar.dashboard-page.component';

const routes:Routes=[
    {path: 'solar', loadChildren: './modules/solar/solar.module#SolarModule', canActivate: [AuthGuard] }
]


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

export class SolarRoutingModule{}

0 个答案:

没有答案