0

I have an angular 2 application that I am building while watching a video tutorial. But the problem is that I referenced the files very well but i am having page not found in the console of my browser. HERE IS THE CODE OF MY COMPONENT

@Component({
   moduleId: module.id,
   selector: 'my-employee',
   templateUrl: '.Employee/employee.component.html'
})
export class EmployeeComponent {
   firstName: string = 'Mr X';
   lastName: string = 'Johnson';
   gender: string = 'Male';
   age: number = 20;
}

The templateUrl is properly referenced but i am still getting page nof found error. Please any help will be highly welcomed. Thanks. UPDATE: STRUCTURE OF PROJECT enter image description here

5
  • Can you post your project structure ? Commented Sep 1, 2017 at 4:35
  • I just did crude update could not find a better way to update the project structure. Commented Sep 1, 2017 at 5:06
  • I am talking about screenshot of project structure. Commented Sep 1, 2017 at 5:12
  • Just uploaded it. Commented Sep 1, 2017 at 5:19
  • Please review posted answer, if still face any issue then post me in answer's comment. Commented Sep 1, 2017 at 5:24

2 Answers 2

1

Hello can you please try:

templateUrl: './employee.component.html'

It's path issue. You do not need to add Employee in the teamplateURL.

Here's the full code:

@Component({
    moduleId: module.id,
    selector: 'my-employee',
    templateUrl: './employee.component.html'
})
export class EmployeeComponent {
    firstName: string = 'Mr X';
    lastName: string = 'Johnson';
    gender: string = 'Male';
    age: number = 20;

    constructor() {
    }
}
Sign up to request clarification or add additional context in comments.

3 Comments

I tried the solution you posted but the problem still persist. I am getting localhost:59956/src/app/Employee/employee.component.html 404 (Not Found) localhost:59956/src/app/Employee/employee.component.html ; Zone: <root> ; Task: Promise.then ; Value: Failed to load localhost:59956/src/app/Employee/employee.component.html undefined
Thanks your answer was helpful. I have resolved the problem now.
Thanks your answer was helpful. I have resolved the problem now.
1

As employee.component.html and employee.component.ts are in same folder then no need to add Employee/employee.component.html in template url path. Also you are using only '.' before a folder name so just change it to './employee.component.html'. Hope ut will work.

Comments

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.