MunirohMansoor
MunirohMansoor

Reputation: 355

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'. 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

Answers (1)

Yoav Schniederman
Yoav Schniederman

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

Related Questions