0
私の遅延読み込みルートを壊すことによってアプリケーションをモジュール化してビルドしようとしています。ここで私は、その後角度のある遅延ロードルート上で '未定義'のNgModuleメタデータが見つかりません
import { BrowserModule } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { MaterialModule } from '@angular/material';
import { routes } from './user.routes';
import { AccessLevel0Guard } from '../guards/level0.guard';
import { SignUpComponent } from './signup/signup.component';
import { TeamsPageComponent } from './teams/teamspage.component';
import { TeamsListComponent } from './teams/teamslist.component';
import { TeamUsersComponent } from './teams/team-users.component';
import { EditTeamComponent } from './teams/edit-team.component';
import { UsersPageComponent } from './users/userspage.component';
import { CreateUserComponent } from './users/create-user.component';
import { UserPermissionComponent } from './users/user-permission.component';
import { EditUserComponent } from './users/edit-user.component';
@NgModule({
declarations: [
/**
* Components/Directives/ Pipes
*/
SignUpComponent,
TeamsPageComponent,
TeamsListComponent,
TeamsUsersComponent,
EditTeamComponent,
UsersPageComponent,
CreateUserComponent,
UserPermissionComponent,
EditUserComponent
],
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
RouterModule.forChild(routes),
]
})
export class UserModule {
public static routes = routes;
}
にインポートしてからindex.tsファイル
にexport { UserModule } from './user.module';
を使用して、エクスポート私のコードは、子ルート
import { SignUpComponent } from './signup/signup.component';
import { TeamsPageComponent } from './teams/teamspage.component';
import { TeamsListComponent } from './teams/teamslist.component';
import { TeamUsersComponent } from './teams/team-users.component';
import { EditTeamComponent } from './teams/edit-team.component';
import { UsersPageComponent } from './users/userspage.component';
import { CreateUserComponent } from './users/create-user.component';
import { UserPermissionComponent } from './users/user-permission.component';
import { EditUserComponent } from './users/edit-user.component';
import { AuthGuard } from '../guards/auth.guard';
import { AccessLevel0Guard } from '../guards/level0.guard';
export const routes = [
{ path: '',
children: [
{ path: '', component: TeamsListComponent, canActivate: [AccessLevel0Guard] },
{ path: ':teamId/edit', component: EditTeamComponent },
{
path: ':teamId/users', component: UsersPageComponent,
children: [
{ path: '', component: TeamUsersComponent },
{ path: 'create/:id', component: CreateUserComponent },
{ path: ':id/permission', component: UserPermissionComponent },
{ path: ':id/edit', component: EditUserComponent }
]
}],
];
に次のようになります
その後、親ルートで以下を使用しました
import { Routes } from '@angular/router';
import { BaseComponent } from './base/base.component';
import { AppComponent } from './app.component';
import { SignInComponent } from './signin/signin.component';
import { UserModule } from './user/user.module.ts';
import { AuthGuard } from './guards/auth.guard';
import { DashboardPageComponent } from './dashboard-graph/dashboard.component';
import { NoContentComponent } from './no-content/no-content.component';
import { DataResolver } from './app.resolver';
export const ROUTES: Routes = [
{
path: '', component: AppComponent,
children: [
{ path: '', component: SignInComponent },
{
path: 'dashboard',
component: BaseComponent,
canActivate: [AuthGuard],
children: [
{ path: '', component: DashboardPageComponent },
{
path: 'teams', loadChildren: './+user#UserModule'
},
]
}
]
},
{ path: '**', component: NoContentComponent }
];
私は私が手にモジュール化ルートをロードしようとすると、これは、その後うまく@NgModule
imports: [
BrowserModule,
BrowserAnimationsModule,
RouterModule,
NgxDatatableModule,
FormsModule,
ReactiveFormsModule,
HttpModule,
MaterialModule,
LeafletModule,
RouterModule.forRoot(ROUTES, { useHash: false, preloadingStrategy: PreloadAllModules })
],
メインルート負荷までに、以下の構成と私のapp.module.tsにインポートされますが以下のエラー。
No NgModule metadata found for 'undefined'