我有一个角度应用程序,在其中我正在执行延迟加载。我的文件夹结构是这样的
app
modules
shipper
addshipper
shipper
shipper.module.ts
shipper.routing.module.ts
transporter
app.routing.module.ts
app.module.ts
在我,app-routing.module.ts
我有lazyload
我shipper
module
这样的
{ path: 'addshipper', loadChildren : './modules/shipper/shipper.module#ShipperModule'}
在我shipper.module.ts
我有以下
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AddshipperComponent } from './addshipper/addshipper.component';
import { ShipperRoutingModule } from './shipper-routing.module';
export const options: Partial<IConfig> | (() => Partial<IConfig>) = null;
@NgModule({
declarations: [
AddshipperComponent
],
imports: [
BrowserModule,
ShipperRoutingModule
],
providers: []
})
export class ShipperModule { }
我内心shipper.module.ts
有以下关注child
routes
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AuthGuard } from '@app/authguard.guard';
import { AddshipperComponent } from './addshipper/addshipper.component';
const routes: Routes = [
{
path: '',
children: [
{ path: '', component: AddshipperComponent,canActivate: [AuthGuard] }
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ShipperRoutingModule { }
在side nave
我的应用程序中,我有这样的链接
<a routerLink="/addshipper" class="nav-link">
<i class="fa fa-circle nav-icon"></i>
<p>Add Shipper</p>
</a>
但问题是,当我点击Add Shipper
链接,所以我得到这个error
在console
Uncaught (in promise): Error: Cannot find module './modules/shipper/shipper.module'
我认为您需要在shipper.module.ts中导入CommonModule
imports: [CommonModule,
BrowserModule, ShipperRoutingModule ],
并且您需要导出公共组件
exports:[AddshipperComponent]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句