URL无法显示Angular Lazy加载组件,请导航至正确的URL

时间:2019-07-01 15:06:08

标签: angular angular6 angular7 loading lazy-evaluation

Im构建具有多屏幕的Angular7应用。 和即时通讯使用延迟加载。 无法弄清楚为什么屏幕没有显示在延迟加载内部模块中。 (即使我在父级中放置路由器出口,URL也已更改,但该组件仍未显示)

*********app.routing.module.ts*******

const routes: Routes = [

  {
    path: '', component: HomepageComponent, canActivate: [AuthGuard],
    children: [
      {
        path: 'search', component: SearchOutletComponent,
        loadChildren: './personal-info/personal.module#PersonalModule'
      },
      { path: "y", component: DateReport},
      { path: "test", component: TestReport},


    ],
  },
  {
    path: 'Login', children: [
      { path: '', component: LoginComponent }
    ]
  },
  { path: '**', redirectTo: 'Login' }

];



*********Personal.routing.module.ts*******

const routes: Routes = [

  {
    path: 'personal-info', component: PersonalInfoOutletComponent,
    children: [
      { path: '', component: PersonalInfoComponent },
      {
        path: 'fund',
        loadChildren: './fund-details/fund.module#FundlModule',
      },
    ]
  },
  { path: '', component: SearchComponent },

];


*******Fund Module*******

const routes: Routes = [
    { path: '', component: FundDetailsComponent }
];

@NgModule({
    declarations:
        [
            FundDetailsComponent
        ],
    imports: [
        SharedModule,
        CommonModule,
        PersonalModule,
        MaterialModule,
        RouterModule.forChild(routes)
    ],
    exports: [RouterModule],
    entryComponents: [UserDetailsComponent]
})
export class FundlModule { }

所以当我试图让奈夫盖特去 localhost:4200 / search / personal-info / fund <<我看到F12中已加载了惰性加载,并且URL已更改!但资金的组成部分没有显示。取而代之的是,我获取了此路线的“ {路径:”,组件:SearchComponent},” 而且我想为什么呢?如果我删除这条路径,我将获得预期的适当资金部分。

所有组件,例如

 SearchOutletComponent,PersonalInfoOutletComponent

have "<router-outlet></router-outlet>在里面,这样他们可以给孩子看。

0 个答案:

没有答案