Reputation: 355
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'.
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
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?
Upvotes: 0
Views: 1416
Reputation: 5391
you need to decleare your component at your JobRoutingModule and not your app module.
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
declarations: [ JobComponent, JobfileComponent ]
})
export class JobRoutingModule {}
and remove export class JobModule { } you not use it
Upvotes: 1