[英]Error: No NgModule metadata found for 'module'
I am new to angular2, i want to put multiple component in one routing.module.ts and multiple module in one module.ts.But i got an error Error: No NgModule metadata found for 'JobfileModule'.
我是angular2的新手,我想将多个组件放在一个routing.module.ts中,将多个模块放在一个module.ts中。但是我收到一个错误
Error: No NgModule metadata found for 'JobfileModule'.
I have searh for any possible solution but i still cannot solve it and still confused with my style of code. 我有任何可能的解决方案,但是我仍然无法解决它,并且仍然对我的代码风格感到困惑。
this is my code 这是我的代码
routing.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { JobComponent } from './job.component';
import { JobfileComponent } from './jobfile.component';
const routes: Routes = [
{
path: '',
component: JobComponent, data: {
title: 'Job' }
},
{
path: '',
component: JobfileComponent, data: {
title: 'JobFile' }
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class JobRoutingModule {}
and my module.ts
和
my module.ts
import { NgModule } from '@angular/core';
import { ChartsModule } from 'ng2-charts/ng2-charts';
import { JobComponent } from './job.component';
import { JobfileComponent } from './jobfile.component';
import { JobRoutingModule } from './job-routing.module';
@NgModule({
imports: [
JobRoutingModule,
ChartsModule
],
declarations: [ JobComponent, JobfileComponent ]
})
export class JobModule { }
export class JobfileModule { }
What is wrong with my code? 我的代码有什么问题?
you need to decleare your component at your JobRoutingModule and not your app module. 您需要在JobRoutingModule而不是应用模块上清除组件。
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
declarations: [ JobComponent, JobfileComponent ]
})
export class JobRoutingModule {}
and remove export class JobModule { } you not use it 并删除不使用的导出类JobModule {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.