다른 ts 파일에 라우팅 구성 세부 사항을 넣을 때 아래 오류가 발생합니다. 그러나 boot.ts 파일에 경로 구성을 넣으면 제대로 작동합니다.라우팅 구성을 Angular4의 별도 ts 파일에 넣는 중 오류 발생
Unhandled Promise rejection: Component DashboardComponent is not part of any NgModule or the module has not been imported into your module. ; Zone: ; Task: Promise.then ; Value: Error: Component DashboardComponent is not part of any NgModule or the module has not been imported into your module.
app.routing.ts :
import { ModuleWithProviders } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { DashboardComponent } from './Components/dashboard/dashboard.component';
const appRoutes: Routes = [
{ path: '', redirectTo: 'Dashboard', pathMatch: 'full' },
{ path: 'Dashboard', component: DashboardComponent },
];
export const AppRouting = RouterModule.forRoot(appRoutes, {
enableTracing: true
});
boot.ts
//other imports
import { AppRouting } from './app.routing';
@NgModule({
imports: [BrowserModule,
//AppRouting,
RouterModule.forRoot(appRoutes, { enableTracing: true }), // <-- debugging purposes only
AgGridModule.forRoot(),
MaterialModule,
SlimLoadingBarModule.forRoot(),
ToastyModule.forRoot(),
BrowserAnimationsModule, FormsModule,
HttpModule, TreeModule, GrowlModule, FileUploadModule, InputTextModule, ButtonModule, ConfirmDialogModule, NgxChartsModule
, AgmCoreModule.forRoot({ apiKey: 'AIzaSyC9TWEHsjWT_QX_Rxl8VXtnnY582aY4mBQ' }) //Angular Google Map Setup
],
providers: [BaseComponentService, TreeNodeService, LowryToastyService],
declarations: [APP_COMPONENTS],
entryComponents: [ENTRY_COMPONENTS],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule { }
아마도 도움이 될까요? https://stackoverflow.com/questions/39527722/angular-2-component-is-not-part-of-any-ngmodule-> "그래서 노선은 대문자의 차이로 인해 모듈이 다른 구성 요소를로드한다고 생각합니다. 이는 루트에 뽑힌 모듈이 모듈과 같은 것이 아님을 의미합니다. " – mwager
감사합니다 @ mwager. 그것은 오류를 해결하는 데 도움이. –