Javascript 角度2-在嵌套管线中找不到模块
我尝试使用Lazyload路线,但没有嵌套。但我仍然得到错误,它没有找到2级路由中的模块 以下是我的构想: app.module.ts:Javascript 角度2-在嵌套管线中找不到模块,javascript,angular,typescript,angular2-routing,Javascript,Angular,Typescript,Angular2 Routing,我尝试使用Lazyload路线,但没有嵌套。但我仍然得到错误,它没有找到2级路由中的模块 以下是我的构想: app.module.ts: import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angul
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { routing } from './app.routes';
import { AppComponent } from './app.component';
import { RouterModule } from '@angular/router';
@NgModule({
declarations: [
AppComponent,
AuthComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
routing
],
exports: [RouterModule],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import { NgModule } from '@angular/core';
import { routing } from './portal.routes';
import { PortalComponent } from './portal.component';
import { FormsModule,ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
routing
],
exports: [ RouterModule ],
declarations: [
PortalComponent
],
providers: [
]
})
export class PortalModule { }
import { NgModule } from '@angular/core';
import { routing } from './test.routes';
import { TestComponent } from './test.component';
import { FormsModule,ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
routing
],
exports: [ RouterModule ],
declarations: [
TestComponent
],
providers: [
]
})
export class TestModule { }
app.routes.ts
import { Router, RouterModule} from '@angular/router';
import { AuthGuard } from './Auth/Services/auth-guard.service';
import { AuthComponent } from './Auth/auth.component';
export const routing = RouterModule.forRoot([
{ path: '', redirectTo: "portal", pathMatch: 'full'},
{ path: 'portal', loadChildren: './Portal/portal.module#PortalModule'},
{ path: '**', redirectTo: "portal"}
])
Portal/Portal.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { routing } from './app.routes';
import { AppComponent } from './app.component';
import { RouterModule } from '@angular/router';
@NgModule({
declarations: [
AppComponent,
AuthComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
routing
],
exports: [RouterModule],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import { NgModule } from '@angular/core';
import { routing } from './portal.routes';
import { PortalComponent } from './portal.component';
import { FormsModule,ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
routing
],
exports: [ RouterModule ],
declarations: [
PortalComponent
],
providers: [
]
})
export class PortalModule { }
import { NgModule } from '@angular/core';
import { routing } from './test.routes';
import { TestComponent } from './test.component';
import { FormsModule,ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
routing
],
exports: [ RouterModule ],
declarations: [
TestComponent
],
providers: [
]
})
export class TestModule { }
Portal/Portal.routes.ts:
import { Router, RouterModule} from '@angular/router';
import { PortalComponent } from './portal.component';
export const routing = RouterModule.forChild([
{ path: '', redirectTo: "reports"},
// This Part doesn't work
{ path: 'reports', component: PortalComponent, loadChildren: './Portal/Test/test.module#TestModule'},
// --
{ path: '**',component: PortalComponent, pathMatch: 'full'}
])
门户/测试/测试模块.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { routing } from './app.routes';
import { AppComponent } from './app.component';
import { RouterModule } from '@angular/router';
@NgModule({
declarations: [
AppComponent,
AuthComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
routing
],
exports: [RouterModule],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import { NgModule } from '@angular/core';
import { routing } from './portal.routes';
import { PortalComponent } from './portal.component';
import { FormsModule,ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
routing
],
exports: [ RouterModule ],
declarations: [
PortalComponent
],
providers: [
]
})
export class PortalModule { }
import { NgModule } from '@angular/core';
import { routing } from './test.routes';
import { TestComponent } from './test.component';
import { FormsModule,ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
routing
],
exports: [ RouterModule ],
declarations: [
TestComponent
],
providers: [
]
})
export class TestModule { }
入口/测试/测试路径:
import { Router, RouterModule} from '@angular/router';
import { TestComponent } from './test.component';
export const routing = RouterModule.forChild([
{ path: '', redirectTo: "reports"},
{ path: 'reports', component: TestComponent},
])
我的错误:
EXCEPTION: Uncaught (in promise): Error: Cannot find module './Portal/Test/test.module'.
Error: Cannot find module './Portal/Test/test.module'.
我现在的问题是他为什么找不到模块?
我也尝试过其他途径,但我认为这是唯一一条真正可行的途径
我需要做什么来修复,或者angular 2不能这样做
(错误是testet with ng serve而不是build | testet with Chrome)不确定这是否有帮助,但我处理模块的方法是将每个模块文件命名为index.ts,并在引用它们时指定文件夹的路径。我从未遇到过找不到模块的问题。查看如何加载异步模块的示例。不确定这是否有帮助,但我创建模块的方法是将每个模块文件命名为index.ts,并在引用它们时指定文件夹的路径。我从未遇到过找不到模块的问题。看一看如何加载异步模块的示例。这个问题出现在旧的@angular/路由器上,我现在更新到3.1.0之前的3.2.0上。这个问题出现在旧的@angular/路由器上,我现在更新到3.1.0之前的3.2.0上。这个路径有效吗?{path:'reports',component:PortalComponent,loadChildren:'./Test/Test.module#TestModule'}?不,我真的尝试了几乎所有的东西为什么有这个组件:PortalComponent?在{path:'reports',component:PortalComponent,loadChildren:'./Test/Test.module#TestModule'}中初始化一个模板,并在这些路由中执行一些全局操作该路径有效吗?{path:'reports',component:PortalComponent,loadChildren:'./Test/Test.module#TestModule'}?不,我真的尝试了几乎所有的东西为什么有这个组件:PortalComponent?在{path:'reports',component:PortalComponent,loadChildrent:'./Test/Test.module#TestModule'}中,初始化一个模板并在这些路径中执行一些全局操作。您的git不是相同的构造,因为只有一个级别的孩子。您的git不是相同的构造,因为只有一个级别的孩子