AngularCli将节点模块导入angular app.module loadChildren
我想从节点模块导入我的模块。 这个节点模块也有我需要导航的路由 我需要的结果: 将my app.module连接起来,以便从节点模块中的模块加载子项。TestModule需要连接到forRoot,以便我可以延迟加载TestModule路由 TestModule是一个dist文件夹,已使用angular cli版本6内置ng Packager添加到节点模块中 这是我的核心应用模块:AngularCli将节点模块导入angular app.module loadChildren,angular,npm,webpack,angular-cli,angular-cli-v6,Angular,Npm,Webpack,Angular Cli,Angular Cli V6,我想从节点模块导入我的模块。 这个节点模块也有我需要导航的路由 我需要的结果: 将my app.module连接起来,以便从节点模块中的模块加载子项。TestModule需要连接到forRoot,以便我可以延迟加载TestModule路由 TestModule是一个dist文件夹,已使用angular cli版本6内置ng Packager添加到节点模块中 这是我的核心应用模块: import { BrowserModule } from '@angular/platform-browser';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { TestModule } from "test";
@NgModule({
declarations: [
AppComponent
],
imports: [
TestModule,
BrowserModule,
RouterModule.forRoot(
[
{
path: "",
redirectTo: "test",
pathMatch: "full"
},
{
path: "test",
loadChildren: "test#TestModule"
},
])
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { HomeComponent } from './containers/home/home.component';
import { LayoutSidebarComponent } from './layouts/layout-sidebar/layout-sidebar.component';
const COMPONENTS = [
HomeComponent
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild([
{
path: '',
pathMatch: 'full',
component: LayoutSidebarComponent,
children: [
{
path: '',
component: HomeComponent
}
]
}
])
],
declarations: [...COMPONENTS],
exports: []
})
export class TestModule {}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"types": [
"node"
]
},
"include": [
"../node_modules/test/**/*.ts"
],
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
这是导入的TestModule(即npm包):
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { TestModule } from "test";
@NgModule({
declarations: [
AppComponent
],
imports: [
TestModule,
BrowserModule,
RouterModule.forRoot(
[
{
path: "",
redirectTo: "test",
pathMatch: "full"
},
{
path: "test",
loadChildren: "test#TestModule"
},
])
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { HomeComponent } from './containers/home/home.component';
import { LayoutSidebarComponent } from './layouts/layout-sidebar/layout-sidebar.component';
const COMPONENTS = [
HomeComponent
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild([
{
path: '',
pathMatch: 'full',
component: LayoutSidebarComponent,
children: [
{
path: '',
component: HomeComponent
}
]
}
])
],
declarations: [...COMPONENTS],
exports: []
})
export class TestModule {}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"types": [
"node"
]
},
"include": [
"../node_modules/test/**/*.ts"
],
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
这是我的核心应用程序tsconfig.aoo.json:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { TestModule } from "test";
@NgModule({
declarations: [
AppComponent
],
imports: [
TestModule,
BrowserModule,
RouterModule.forRoot(
[
{
path: "",
redirectTo: "test",
pathMatch: "full"
},
{
path: "test",
loadChildren: "test#TestModule"
},
])
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { HomeComponent } from './containers/home/home.component';
import { LayoutSidebarComponent } from './layouts/layout-sidebar/layout-sidebar.component';
const COMPONENTS = [
HomeComponent
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild([
{
path: '',
pathMatch: 'full',
component: LayoutSidebarComponent,
children: [
{
path: '',
component: HomeComponent
}
]
}
])
],
declarations: [...COMPONENTS],
exports: []
})
export class TestModule {}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"types": [
"node"
]
},
"include": [
"../node_modules/test/**/*.ts"
],
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
信息:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { TestModule } from "test";
@NgModule({
declarations: [
AppComponent
],
imports: [
TestModule,
BrowserModule,
RouterModule.forRoot(
[
{
path: "",
redirectTo: "test",
pathMatch: "full"
},
{
path: "test",
loadChildren: "test#TestModule"
},
])
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { HomeComponent } from './containers/home/home.component';
import { LayoutSidebarComponent } from './layouts/layout-sidebar/layout-sidebar.component';
const COMPONENTS = [
HomeComponent
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild([
{
path: '',
pathMatch: 'full',
component: LayoutSidebarComponent,
children: [
{
path: '',
component: HomeComponent
}
]
}
])
],
declarations: [...COMPONENTS],
exports: []
})
export class TestModule {}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"types": [
"node"
]
},
"include": [
"../node_modules/test/**/*.ts"
],
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
当我对端口localhost:4200执行ng服务时,没有控制台错误和git命令错误
我将angular cli 6与angular 6、ng Packager、webpack和iterm一起用于git cli
很难调试,因为我没有错误可处理。
但是,核心应用程序模块似乎没有加载。好的,当您延迟加载模块时,您不能同时导入它 尝试从app.module.ts中的导入中删除TestModule