【发布时间】:2017-10-22 07:22:04
【问题描述】:
我正在 Angular4 中实现一个演示项目,我也是这个(Angular4)的新手。我看过一个链接,Angular2 module has no exported member,但我无法解决这个问题。
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)
}
}
我想添加 AboutusComponent 而不是编译失败。
我想在 angular4 中添加新模块 请分享你的想法。
【问题讨论】: