2016-07-14 7 views
4

다른 응용 프로그램에서 내 응용 프로그램의 구성 요소를 사용하려고합니다. 내 프로젝트는 동일한 폴더에 있으므로 작동 할 것이라고 생각했지만 "모듈을 찾을 수 없음"예외가 발생했습니다. 할 방법이 있습니까? 또는 이것을 달성하는 다른 방법은?Angular2- 다른 응용 프로그램의 구성 요소 사용

무엇 내가 지금까지했던 것은 :

import { Component, OnInit } from '@angular/core'; 
import { OverviewPaginationComponent } from './../../../../overview/src/app/overview-pagination/overview-pagination.component.ts'; 

@Component({ 
    moduleId: module.id, 
    selector: 'combi', 
    template: ` 
<overview-pagination><overview-pagination> 

`, 
    styleUrls: ['combi.component.css'], 
    providers: [], 
    directives: [OverviewPaginationComponent] 
}) 
export class CombiComponent implements OnInit { 

    constructor() {} 

    ngOnInit() { 
    } 

} 

을 그리고 systemConfig 정의 :

const barrels: string[] = [ 
    // Angular specific barrels. 
    '@angular/core', 
    '@angular/common', 
    '@angular/compiler', 
    '@angular/forms', 
    '@angular/http', 
    '@angular/router', 
    '@angular/platform-browser', 
    '@angular/platform-browser-dynamic', 
    '@angular/router-deprecated', 

    // Thirdparty barrels. 
    'rxjs', 

    // App specific barrels. 
    'app', 
    'app/shared', 
    'app/combi', 
    '../../overview/src/app/overview-pagination', 
    /** @cli-barrel */ 
]; 

답변

0

당신은 당신이 '기능'의 상위 모듈에 사용하려는 구성 요소를 추가해야 당신은 그 구성 요소를 사용할 것입니다. 예를 들어이 모듈이 OverviewPaginationComponent를 사용하려고하는 상위 모듈이라고 가정합니다.

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

import { AppRoutingModule } from './app-routing.module'; 
import { AppComponent } from './app.component'; 
import { OverviewPaginationComponent } from 'path'; 


@NgModule({ 
    declarations: [ 
    AppComponent, 
    OverviewPaginationComponent 
    ], 
    imports: [ 
    BrowserModule, 
    AppRoutingModule 
    ], 
    providers: [], 
    bootstrap: [AppComponent] 
}) 
export class AppModule { } 
관련 문제