简体   繁体   中英

./src/app/component/header.component.ts Module not found: Error: Can't resolve './header.component.html

when i installed the angular it initailly shown me the default angular output.but when i created the header component ,its showimg the error like this..please can anyone resolve my pbm..?

i tried the solutions which was given by stackoverflow,but its not working

import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-header',enter code here
templateUrl: `header.component.html
`,
styleUrls: []
})
export class HeaderComponent implements OnInit {
constructor() {}
ngOnInit() {}
}

An Error occurs may be if the path for HTML file is not found. Change this templateUrl in your code

templateUrl: './header.component.html',

and add your component to module.ts file

declarations: [HeaderComponent]

Provide relative path instead of absolute path.

As in if your html is in the same folder

templateUrl: `./header.component.html'

instead of

templateUrl: `header.component.html`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM