1
我創造的角2 CLI應用程序,我的應用程序模塊會太長所以現在我想創建子模塊如何使用角度CLI
創建子模塊我的子模塊
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
import { ProjectComponent } from './project.component';
import { ProjectListingComponent } from './project-listing/project-listing.component';
import { ProjectCreateUpdateComponent } from './project-create-update/project-create-update.component';
// routing set for project module
const routes: Routes = [
{path:'project/add' , component:ProjectCreateUpdateComponent},
{path:'project/:id/edit' , component:ProjectCreateUpdateComponent},
{path:'project-listing' ,component:ProjectListingComponent},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
providers: []
})
export class ProjectRoutingModule { }
// Main module for project
@NgModule({
imports: [
CommonModule,
ProjectRoutingModule
],
declarations: [ProjectComponent, ProjectListingComponent, ProjectCreateUpdateComponent ]
})
export class ProjectModule { }
>主模塊是
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { DatePipe } from '@angular/common';
//import { ViewContainerRef} from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { routing } from './app.routing';
import { ReactiveFormsModule } from '@angular/forms';
import { MaterialModule } from '@angular/material';
//custom modules
import {ProjectModule} from './project_module/project.module';
import { HomeComponent } from './home/home.component';
...
@NgModule({
declarations: [
AppComponent,
GradeComponent,
GradeListingComponent,
HomeComponent,
GradeComponent,
...
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
routing,
MaterialModule.forRoot(),
ReactiveFormsModule,
ProjectModule
],
providers: [
NotificationsService,
DatePipe,
GradeService,
...
],
exports: [
ConfirmDialogComponent,
],
entryComponents: [
logsShow
],
bootstrap: [AppComponent]
})
export class AppModule { }
乙UT問題來了我的子模塊無法訪問材料模塊值 和其他模塊/插件我在app.module使用..
是什麼讓這個方式..也面臨着路由
感謝名單,以及如何處理子模塊與主路由的路由? – Ash