Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 默认路由模块与其他模块一起加载_Angular_Typescript_Lazy Loading_Angular Router - Fatal编程技术网

Angular 默认路由模块与其他模块一起加载

Angular 默认路由模块与其他模块一起加载,angular,typescript,lazy-loading,angular-router,Angular,Typescript,Lazy Loading,Angular Router,我已将my lazy loaded Home模块设置为空路径。但现在的问题是,每当我尝试加载不同的模块,例如通过其url(如/new/auth)登录时,主模块也会随之加载 const routes: Routes = [ { path: '', component: MainLayoutComponent, children: [ { path: '', loadChildren: './homepage/homepage.modu

我已将my lazy loaded Home模块设置为空路径。但现在的问题是,每当我尝试加载不同的模块,例如通过其url(如/new/auth)登录时,主模块也会随之加载

const routes: Routes = [
  {
    path: '', component: MainLayoutComponent,
    children: [
      {
        path: '',
        loadChildren: './homepage/homepage.module#HomepageModule'
      },
      {
        path: 'new/auth',
        loadChildren: './auth/auth.module#AuthModule'
      },
    }
 }
由于我使我的主页模块延迟加载,所以我希望主页模块只能在空路径上加载。但是每一条路线都有载货


我像app module或任何其他根模块一样到处检查,并且没有导入home module。

子数组中项目的顺序很重要

试一试


子项
数组中项的顺序很重要

试一试

const routes: Routes = [
  {
    path: '', component: MainLayoutComponent,
    children: [
     {
        path: 'new/auth',
        loadChildren: './auth/auth.module#AuthModule'
      },
      {
        path: '',
        loadChildren: './homepage/homepage.module#HomepageModule'
      },
    }
 }