0

I am implementing one demo project in Angular4 and I am also new in this(Angular4). I have seen one link,Angular2 module has no exported member, But I am not able to solve this problem.

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { VideoListComponent } from './training/video-list.component';  
import { HomeComponent } from './training/home.component';     
import { AddVideoComponent } from './training/add-video.component';
import { AboutusComponent } from './training/aboutus.component';


@NgModule({
  declarations: [
    AppComponent,
    VideoListComponent,
    HomeComponent,      
    AddVideoComponent,
    AboutusComponent        
  ],
  imports: [
    BrowserModule,
    HttpModule,
    FormsModule,
    ReactiveFormsModule,
    RouterModule.forRoot([
      {path: 'home', component:HomeComponent},     
      {path: 'videos', component:VideoListComponent},          
      {path :'newvideo',component:AddVideoComponent},
      {path: 'aboutus', component:AboutusComponent},
      {path: '', redirectTo:'home',pathMatch:'full'},
      {path: '**', redirectTo:'home',pathMatch:'full'}
    ])
  ],    
  bootstrap: [AppComponent]
})
export class AppModule { }

aboutus.component.ts

import { Component } from '@angular/core';
console.log('It works here');
@Component({
    moduleId: module.id,
    templateUrl: 'aboutus.html'
})

export class AboutusComponent {
    s: string = "Hello";
    constructor() {
        console.log(this.s)
    }
}

I want to add AboutusComponent than it is giving compile failed.

I am sharing my directory structure enter image description here

It give me some error in browser(in below screen shot). enter image description here

I want to add new module in angular4 Please share your idea.

Varun Sharma
  • 3,782
  • 7
  • 37
  • 84

1 Answers1

0

You have missed the Component Selector in the AboutusComponent.

It should be

import { Component } from '@angular/core';
console.log('It works here');
@Component({
    selector: 'aboutus', // the selector is missing in your component
    moduleId: module.id,
    templateUrl: 'aboutus.html'
})

export class AboutusComponent {
    s: string = "Hello";
    constructor() {
        console.log(this.s)
    }
}
Rahul Singh
  • 16,265
  • 5
  • 49
  • 74