".... has no exported member" -error in import component (Angular)

I am making a component called headerComponent and importing it in app.component.ts, but getting the website / src / app / header / app.headerComponent "" does not have the headerComponent exported element error. My app.headerComponent.ts code is how to follow

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

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

      

and the app.component.ts code looks like this

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 {
   }

      

+3


source to share


2 answers


You need to add the component to module.ts

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

      



then

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

      

+1


source


Fixed a similar bug by updating the Typescript version



0


source







All Articles