我正在处理一个模板,该模板具有很多组件,并且使用延迟加载进行路由。我删除了所有内置组件以及路由文件。我创建了自己的组件和普通的路由模块文件。
这是路由模块文件:
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { TicketsComponent } from './tickets/tickets.component';
import { AddTicketComponent } from './tickets/add-ticket/add-ticket.component';
import { MainComponent } from './main/main.component';
import { EditTicketComponent } from './tickets/edit-ticket/edit-ticket.component';
import { TicketDetailComponent } from './tickets/ticket-detail/ticket-detail.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { LoginComponent } from './auth/login/login.component';
import { SignupComponent } from './auth/signup/signup.component';
const routes: Routes = [,
{path: 'login', component: LoginComponent},
{path: 'signup', component: SignupComponent},
{path: '', component: MainComponent, children: [
{path: 'tickets', component: TicketsComponent, pathMatch: 'full', data: {breadcrumb: 'Tickets'}},
{path: 'tickets/add', component: AddTicketComponent, pathMatch: 'full', data: {breadcrumb: 'Ticket'}},
{path: 'tickets/:id', component: TicketDetailComponent, pathMatch: 'full', data: {breadcrumb: 'Ticket'}},
{path: 'tickets/:id/edit', component: EditTicketComponent, pathMatch: 'full', data: {breadcrumb: 'Modifier le ticket'}}
]},
{path: '**', component: NotFoundComponent}
];
@NgModule({
imports: [
RouterModule.forRoot(routes)
],
exports: [
RouterModule
]
})
export class AppRoutingModule {}
这是应用程序模块文件:
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
PerfectScrollbarModule,
NgbModule,
MultiselectDropdownModule,
AgmCoreModule.forRoot({
apiKey: 'AIzaSyBNcjxo_35qnEG17dQvvftWa68eZWepYE0'
}),
CalendarModule.forRoot(),
ToastrModule.forRoot(),
PipesModule,
ReactiveFormsModule,
CKEditorModule,
AppRoutingModule,
Ng2SmartTableModule
],
declarations: [
AppComponent,
HeaderComponent,
FooterComponent,
SidebarComponent,
VerticalMenuComponent,
HorizontalMenuComponent,
BreadcrumbComponent,
BackTopComponent,
FullScreenComponent,
ApplicationsComponent,
MessagesComponent,
UserMenuComponent,
FlagsMenuComponent,
SideChatComponent,
FavoritesComponent,
NotFoundComponent,
AddTicketComponent,
TicketsComponent,
MainComponent,
EditTicketComponent,
TableComponent,
ToasterComponent,
TicketDetailComponent,
SelectionComponent,
ResponseComponent,
ResponseAddComponent,
ResponseEditComponent,
CommentsComponent,
CommentAddComponent,
SignupComponent,
LoginComponent
],
providers: [
AppSettings,
TicketsService,
ResponseService,
CommentsService,
{ provide: PERFECT_SCROLLBAR_CONFIG, useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG }
],
bootstrap: [ AppComponent ]
})
export class AppModule { }
运行ng服务时,出现此错误:
无法读取未定义的属性'loadChildren'中的错误
即使我在控制台上登录应用程序组件的ngonInit,控制台中也不会显示任何内容。 PS:我没有在项目中的任何地方使用延迟加载。
答案 0 :(得分:0)
屏幕调用堆栈/控制台日志pls,以找出引发错误的确切位置