2016-09-13 13 views
8

私のサンプルアプリケーションでは、 "TempModule"というフィーチャモジュールを作成しましたが、その下に というコードがあります。私はルートモジュール内TempModuleを参照していますモジュール 'TempModule'によって予期しない値 'DecoratorFactory'がインポートされました

import { NgModule } from '@angular/core'; 
import { CommonModule} from '@angular/common'; 

import { TempOneComponent } from './temp.one.component'; 
import { TempTwoComponent } from './temp.two.component'; 
import { tempRouting } from './temp.routing'; 



@NgModule({ 
declarations: [ TempOneComponent, 
       TempTwoComponent], 
imports: [ NgModule, 
      CommonModule, 
      tempRouting] 
}) 

export class TempModule {} 

は、以下のルートモジュールコード

import { NgModule }  from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { FormsModule } from '@angular/forms'; 

//-- routing import 
import { routing, 
     appRoutingProviders} from './app.routing'; 

//-- root component import 
import { AppComponent } from './app.component'; 
import { AppAboutComponent } from './app-about.component'; 
import { AppCreatTicketComponent } from './tickets/ app.create-ticket.component'; 
import { AppOpenTicketComponent } from './tickets/app.open-ticket.component'; 
import { AppSearchTicketComponent } from './tickets/ app.search-ticket.component'; 
import { AppDashboardComponent } from './tickets/app.dashboard.component'; 
import { AppUsersComponent } from './users/app.users.component'; 

import { TempModule } from './tempModule/temp.module'; 

@NgModule({ 
    declarations: [AppComponent , 
    AppAboutComponent , 
    AppCreatTicketComponent, 
    AppOpenTicketComponent, 
    AppSearchTicketComponent, 
    AppDashboardComponent, 
    AppUsersComponent 
    ], 
    imports:  [BrowserModule , 
        FormsModule , 
        routing, 
        TempModule ], 
    providers: [appRoutingProviders], 
    bootstrap: [AppComponent] 

}) 

export class AppModule {} 

である私は、「モジュール 『TempModule』で輸入し、予期しない値 『DecoratorFactory』」アプリケーションを実行するとブラウザコンソールに表示されます。

このエラーの原因は何でしょうか。

答えて

21

decoratorimportsアレイにインポートしようとしています。モジュールのみが含まれている必要があります

@NgModule({ 
    declarations: [ TempOneComponent, 
       TempTwoComponent], 
    imports: [ NgModule, <== why is it here??? 
      CommonModule, 
      tempRouting] 
}) 
export class TempModule {} 
+1

今その作業は、実際にも、エラーの説明が伝え何thatsのが、私はそれを理解するためにわざわざdid'nt ... – refactor

2

別の方法では、間違った場所からモジュールをインポートすることができます。たとえば:

import {CommonModule} from '@angular/core'; // wrong 

は次のようになります。

import {CommonModule} from '@angular/common'; 
関連する問題