3

I am trying to build an angular 7 app and I'm not very familiar with it. Can someone help me understand why it can't find the component.ts files? They exist in the paths the routing module references. I am getting the following error

enter image description here

Here are my components: app-routing.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { ResumeComponent }      from './app/resume/resume.component';
import { HomeComponent }      from './app/home/home.component';
const routes: Routes = [
  { path: 'resume', component: ResumeComponent },
  { path: 'home', component: HomeComponent },
  { path: '',   redirectTo: '/home', pathMatch: 'full' }
];
@NgModule({
declarations: [
  HomeComponent,
  ResumeComponent
],
imports: [
 RouterModule.forRoot(routes)
],
exports: [
   RouterModule
]
})
export class AppRoutingModule { }

Home.Component

 import { Component, OnInit } from '@angular/core';

@Component({
 selector: 'app-home',
 templateUrl: './home.component.html',
 styleUrls: ['./home.component.css']
})
export class HomeComponent {

}   

Resume Component

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-resume',
  templateUrl: './resume.component.html',
  styleUrls: ['./resume.component.css']
})

 export class ResumeComponent { 
 }

enter image description here

1 Answer 1

3

In the last image, there is not app-routing.module.ts, set the file in src/app folder and in the imports, you're must write the proper address, like this.

import { ResumeComponent }      from './resume/resume.component';
import { HomeComponent }      from './home/home.component';

now the router should load the components.

Sign up to request clarification or add additional context in comments.

1 Comment

My path was wrong after all for the components in my router. I think my screenshot was too small to show it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.