angular - "....has no exported member"- 导入组件时出错( Angular )

标签 angular typescript components

我正在制作一个名为 headerComponent 的组件并在 app.component.ts 中导入但获取 website/src/app/header/app.headerComponent"' has no exported member 'headerComponent' 错误我的 app.headerComponent.ts 代码如下关注

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

@Component({
 selector: 'header',
 templateUrl: './app/header/header.html'
 })
 export class headerComponent {}

和app.component.ts代码如下

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

 import { headerComponent } from './header/app.headerComponent';

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

最佳答案

您需要将组件添加到您的 module.ts

import { headerComponent } from './header/app.headerComponent';

然后,

@NgModule({
  imports: [
  ],
  declarations: [
    headerComponent 
  ]

关于angular - "....has no exported member"- 导入组件时出错( Angular ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43212957/

相关文章:

angular - 如何构建 Angular 4.3.6 进行生产?

javascript - httpParams 删除未定义的参数

javascript - 以编程方式实例化 vuetify-components

html - 如何在 Angular 上明智地为组件 View 制作加载器

javascript - Angular 6 中的自定义单选按钮选择错误(在 ngFor 内部)

angular - "You seem to not be depending on "@ Angular/核心 "."

delphi - 您如何找到 Delphi 组件的来源包?

angular - ./src/$$_gendir/app/app.module.ngfactory.ts : Cannot read property 'flags' of undefined 中的错误

typescript - 无服务器 : Not all typescript files compiled within the same directory