2017-07-06 13 views
0

私は単純なAngularJS 2/sアプリを構築しています。ネストされた子コンポーネントの変数を親コンポーネントに渡そうとします。親はそれを変更できます。キャッチされていないエラー:予期しない値 'PropDecoratorFactory'がモジュール 'AppModule'によってインポートされました。 @NgModule注釈を追加してください。

子供:


          
  
@Component({ 
 
     selector: 'app-copm-player', 
 
     templateUrl: './copm-player.component.html', 
 
     styleUrls: ['./copm-player.component.css'] 
 
    }) 
 
    export class CopmPlayerComponent implements OnInit { 
 
     // @Input('isRoundStart') isRoundStart: boolean = false; 
 
     isRoundStart: boolean = false; 
 
     // @Input('RandNum') randNums = 0; 
 
     randNums = 0; 
 
     constructor() { } 
 
     ngOnInit() { 
 
     } 
 

 
    }

親:


          
  
import { Component, OnInit, ViewChild, Input} from '@angular/core'; 
 
    import {CopmPlayerComponent} from './copm-player/copm-player.component'; 
 

 
    @Component({ 
 
     selector: 'app-players-board', 
 
     templateUrl: './players-board.component.html', 
 
     styleUrls: ['./players-board.component.css'], 
 

 
    }) 
 
    export class PlayersBoardComponent implements OnInit { 
 
     @ViewChild(CopmPlayerComponent) compPlayer: CopmPlayerComponent; 
 
     onStartRound(){ 
 
     console.log(this.compPlayer.isRoundStart); 
 
     
 
     this.compPlayer.isRoundStart = true; 
 
     console.log(this.compPlayer.isRoundStart); 
 
     
 
     } 
 
     constructor() { } 
 

 
     ngOnInit() { 
 
     } 
 

 
    }

私のIDEにはprobemがないと言うが、私は全体のアプリケーションを実行しようとすると、私はこのエラーmesssage取得:

> Uncaught Error: Unexpected value 'PropDecoratorFactory' imported by the module 'AppModule'. Please add a @NgModule annotation. 
    at syntaxError (compiler.es5.js:1689) 
    at compiler.es5.js:15373 
    at Array.forEach (<anonymous>) 
    at CompileMetadataResolver.getNgModuleMetadata (compiler.es5.js:15356) 
    at JitCompiler._loadModules (compiler.es5.js:26679) 
    at JitCompiler._compileModuleAndComponents (compiler.es5.js:26652) 
    at JitCompiler.compileModuleAsync (compiler.es5.js:26581) 
    at PlatformRef_._bootstrapModuleWithZone (core.es5.js:4595) 
    at PlatformRef_.bootstrapModule (core.es5.js:4581) 
    at Object.107 (main.ts:10) 

奇妙なことは、私は任意のデコレータ名「PropDecoratorFactory」を見つけることができませんでしたし、私はapp.module.tsには、このようなdeclerationを見ていない:


          
  
import { BrowserModule } from '@angular/platform-browser'; 
 
    import { NgModule } from '@angular/core'; 
 
    import { FormsModule } from '@angular/forms'; 
 
    import { HttpModule } from '@angular/http'; 
 
    import { Input } from '@angular/core'; 
 
    import { ViewChild } from '@angular/core'; 
 
    import { Output } from '@angular/core'; 
 
    import { AppComponent } from './app.component'; 
 
    import { HeaderComponent } from './header/header.component'; 
 
    import { PlayersBoardComponent } from './players-board/players-board.component'; 
 
    import { PlayerComponent } from './players-board/player/player.component'; 
 
    import { ScoresComponent } from './players-board/scores/scores.component'; 
 
    import { CopmPlayerComponent } from './players-board/copm-player/copm-player.component'; 
 

 
    @NgModule({ 
 
     declarations: [ 
 
     AppComponent, 
 
     HeaderComponent, 
 
     PlayersBoardComponent, 
 
     PlayerComponent, 
 
     ScoresComponent, 
 
     ], 
 
     imports: [ 
 
     BrowserModule, 
 
     FormsModule, 
 
     HttpModule, 
 
     ViewChild 
 
     ], 
 
     providers: [], 
 
     bootstrap: [AppComponent] 
 
    }) 
 
    export class AppModule { }

誰もが問題が何であるかを教えてもらえますか?それを修正するために私は何ができますか? ありがとう

答えて

0

あなたはAppModuleのインポートリストからViewChildを削除しなければなりません。

imports: [ 
    BrowserModule, 
    FormsModule, 
    HttpModule, 
    ViewChild <--- Remove this one 
    ], 
+0

ありがとうございました!それを簡単に解決した – mizenetofa1989

関連する問題

 関連する問題