我正在使用 Angular7,并且我正在使用新语法,即 loadChildren 用于延迟加载模块。但是当我提供我的应用程序并检查浏览器时,我发现它没有创建任何块。
以下是我的应用程序路由
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{ path: '', loadChildren: './layout/layout.module#LayoutModule' },
{ path: 'auth', loadChildren: './auth/auth.module#AuthModule' },
{ path: 'not-found', loadChildren: './not-found/not-found.module#NotFoundModule' },
{ path: '**', redirectTo: 'not-found' }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
下面是我的应用程序模块我
mport { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
// imports for internationalization i18n
import { HttpClientModule } from '@angular/common/http';
import { LanguageTranslationModule } from './language-translation/language-translation.module';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
LanguageTranslationModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}