2017-02-15 12 views
1

親コンポーネントから子コンポーネントの関数を呼び出そうとしています。別のコンポーネントからコンポーネントをインポートする

私が理解しているように、これについては、ViewChildを使用することをお勧めします。

私はそれをすべてのロジックを理解し、私は親コンポーネントに子コンポーネントをインポートすることはできません何らかの理由で、それは私にエラーを与える:

は、「モジュールを見つけることができません../claim-header /claim-header.component '。

これは私の親コンポーネントでインポートセクションである:(請求項)

import { ClaimHeaderComponent } from '../claim-header/claim-header.component';

私はそれらすべてを試してみた:

import { ClaimHeaderComponent } from './claim-header'; 
import { ClaimHeaderComponent } from './claim-header/claim-header'; 
import { ClaimHeaderComponent } from '../claim-header'; 
import { ClaimHeaderComponent } from '../../components/claim-header-component'; 

など

参考のため、残りのコンポーネントはコンポーネントでない限り正常に動作します。

import { ClaimDetail } from '../../modules/models/claim'; 
import { ClaimsService } from '../../modules/services/claims.service'; 

は、これは私の子コンポーネントの宣言です:

@Component({ 
    moduleId: module.id, 
    selector: 'fhp-claim-header', 
    templateUrl: 'claim-header.component.html' 
}) 

export class ClaimHeaderComponent implements OnInit { 
    ... 
} 

そして、私のフォルダのレイアウト:

Folder layout

答えて

1

あなたは

../claim-header/claim-header.component 

説明を使用する必要があります。あまりにもupvote

enter image description here

+1

あなたのデモのために>コンポーネントフォルダ

enter image description here

マイフォルダ構造 -

は./根底にあるフォルダのルートフォルダを参照します。あなたを助けてうれしい – Aravind

関連する問題