2017-01-31 18 views
6

CustomerInfoコンポーネントをエクスポートするCustomerInfoModuleというフィーチャー・モジュールがあります。下記参照。角2:モジュール内のコンポーネントをエクスポートし、モジュール内でインポートして使用します。

import {NgModule} from '@angular/core' 
import {RouterModule} from '@angular/router' 

import {CustomerInfoComponent} from './customer-info.component' 

@NgModule({ 
declarations:[CustomerInfoComponent], 
exports:[CustomerInfoComponent] 
}) 
export class CustomerInfoModule{ 
} 

このCustomerInfoComponentをMissedCollectionsComponent内にインポートして使用します。 。私はtypescriptですエラーに

」.module "」を取得しています何のエクスポートメンバーのCustomerInfoComponent"

を持っていないAngular2のドキュメントを1として

import {NgModule} from '@angular/core' 
import {RouterModule} from '@angular/router' 

import {MissedCollectionsComponent} from './missed-collections.component' 

import {CustomerInfoComponent} from '../shared/customer/customer-info.module' 

@NgModule({ 
imports:[RouterModule.forChild([ 
     {path:'missedcollection',component:MissedCollectionsComponent}, 
     {path:'missedcollection/customerinfo',component:CustomerInfoComponent} 
    ]), 
    CustomerInfoModule], 
declarations:[], 
exports:[] 
}) 
export class MissedCollectionsModule{ 

} 

をそれは言う:

'ContactComponentをエクスポートして、 ContactModulをインポートする他のモジュールeをコンポーネントテンプレートに含めることができます。 link

は、それがモジュールからcomponetsをインポートし、別のモジュール内で使用するために論理的ではありません。私は間違っ思考その/または行方不明いろいろ書いアム?

答えて

2

あなたはモジュールファイルからインポートするので、あなたのような何かを行うことができますこれ。

顧客info.module.ts

import {CustomerInfoComponent} from './customer-info.component'; 
export CustomerInfoComponent; 
+0

はいそれは働くだろう。ありがとうございました。しかし、我々は別のモジュールからインポートして、なぜその目に見えないコンポーネントをエクスポートするとき、私の懸念がある。 –

+0

@PrabashB NgModuleの 'exports'は、他のNgModuleを' declarations'で 'imports'している場合、いくつかのComponents、Directives、Pipesの' declarations'を必要としないことに注意してください。ありがとうございます。 –

+0

出来た。あなたのコードに小さな修正。以下のコードは私のために働いた。{CustomerInfoComponent}を「./customer-info.component」からインポートする。 export {CustomerInfoComponent}コードを編集してください。それで私はそれを受け入れます。 –

関連する問題