2017-10-22 5 views
0

私はAngular4でデモプロジェクトを1つ実装していますが、これもまた新しくなっています(Angular4)。私は1つのリンクAngular2 module has no exported memberを見ましたが、私はこの問題を解決することができません。Angular4 giveにエクスポートされたメンバがありません(コンパイルに失敗しました)

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を追加します。

私はそれが私に(下のスクリーンショットで)ブラウザでいくつかのエラーを与える enter image description here

私のディレクトリ構造を共有しています。 enter image description here

私はangular4 に新しいモジュールを追加したい、あなたのアイデアを共有してください。

答えて

0

AboutusComponentのコンポーネントセレクタが見つかりませんでした。

それは私の知る限り、 `selector`はオプションのプロパティです

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) 
    } 
} 
+0

でなければなりません。デフォルトは 'ng-component'です – yurzui

+0

@yurzuiこれは間違っているかもしれませんが、私はidセレクタはオプションではありません。画像に私の目をとらえるものは何もありません –

+0

彼のタブhttp:// takeを見てください。 ms/BpSuW彼はファイルを保存していないようだ。 – yurzui

関連する問題