简体   繁体   English

./src/app/component/header.component.ts 模块未找到:错误:无法解析'./header.component.html

[英]./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..?当我安装 angular 时,它 initailly 向我显示了默认的 angular 输出。但是当我创建标题组件时,它显示了这样的错误..请任何人都可以解决我的 pbm ..?

i tried the solutions which was given by stackoverflow,but its not working我尝试了stackoverflow给出的解决方案,但它不起作用

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.如果未找到 HTML 文件的路径,则可能会发生错误。 Change this templateUrl in your code在您的代码中更改此 templateUrl

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

and add your component to module.ts file并将您的组件添加到 module.ts 文件

declarations: [HeaderComponent]

Provide relative path instead of absolute path.提供相对路径而不是绝对路径。

As in if your html is in the same folder就像你的 html 在同一个文件夹中一样

templateUrl: `./header.component.html'

instead of代替

templateUrl: `header.component.html`

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Angular 7中获取错误./src/app/app.component.ts找不到模块:错误:无法解析 - Get error in Angular 7 ./src/app/app.component.ts Module not found: Error: Can't resolve 错误 in./src/app/app.component.ts 找不到模块:错误:无法解析 './app.component.css' - ERROR in ./src/app/app.component.ts Module not found: Error: Can't resolve './app.component.css' ./src/app/svg.component.ts中的错误找不到模块:错误:无法解析'./svg.component.svg' - ERROR in ./src/app/svg.component.ts Module not found: Error: Can't resolve './svg.component.svg' Angular 4错误-./src/main.ts中找不到错误:错误:无法解析'./$$_gendir/app/app.app.module.ngfactory' - Angular 4 error - ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' /~/src/app/app.component.ts (23:8) 图像中的错误未定义 - Error in /~/src/app/app.component.ts (23:8) images is not defined ./src/main/webapp/app/app.main.ts 中的 Jhipster webpack 生产错误,找不到模块:错误:无法解析“./app.module.ngfactory” - Jhipster webpack production ERROR in ./src/main/webapp/app/app.main.ts ,Module not found:Error: Can't resolve './app.module.ngfactory' src / app / value / value.component.ts(4,15)中的错误:错误TS2580:找不到名称“模块” - ERROR in src/app/value/value.component.ts(4,15): error TS2580: Cannot find name 'module' 我不能直接在HTML中使用app.component.ts以外的文件中定义的组件吗? - Can't I use a component defined in a file other than app.component.ts in HTML directly? ./src/main.ts中的ngcli 6.1.3错误-无法解析'./app/app.module.ngfactory' - ngcli 6.1.3 ERROR in ./src/main.ts - Can't resolve './app/app.module.ngfactory' ./src/polyfills.ts 中的错误未找到模块:错误:无法解析“zone.js/dist/zone” - ERROR in ./src/polyfills.ts Module not found: Error: Can't resolve 'zone.js/dist/zone'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM