2017-09-11 4 views
0

저는 ionic/firebase 응용 프로그램을 가지고 있으며 동일한 기능을 가진 웹 응용 프로그램을 만들고 싶습니다. 나는이 템플릿으로 시작했다 : https://github.com/ng-lisbon/angular-firebase-seed. Angular 4, Firebase 3.9입니다.Angular2 : 구성 요소가 모듈의 일부가 아닙니다.

이제는 부모 구성 요소의 데이터를 @input을 사용하는 자식으로 전달하려고합니다. 거기에 많은 다른 자습서와 스레드가 거기에 관한, 그리고 아직 내 코드에서 내가 뭘 잘못하고 있는지 보지 않습니다.

부모 HTML :

<app-child [message]="parentMessage"></app-child> 

부모 TS :

@Component({ 
    selector: 'app-tester', 
    templateUrl: './collections.component.html', 
    styles: [], 
}) 
export class CollectionComponent implements OnInit { 
    userEmail = ''; 
    alerts = []; 
    collections = []; 
    childData: any; 

    parentMessage = "message from parent" 

@Input() message: any; 

    constructor(...) { 
     ... 
    } 

    ngOnInit() { 
    } 
} 

아이 HTML :

{{message}} 

아이 TS :

@Component({ 
    selector: 'app-child', 
    templateUrl: './collectioninfo.component.html', 
    styles: [] 
}) 
export class CollectionInfo implements OnInit { 
    @Input() message: string; 

    constructor(...) { 

    ngOnInit() {} 
} 

나는 오류 메시지 "오류 :. 구성 요소 CollectionComponent이 모듈에 가져 오지 않은 어떤 NgModule 또는 모듈의 일부가 아닙니다" 오류로 인해 나는 수입과 모듈로 무언가를 엉망으로 만들고있다.

app.module.ts :

import ... 
import { CollectionComponent } from 
'./collections/collections.component'; 
import { CollectionInfo } from './collections/collectioninfo.component'; 

@NgModule({ 
    declarations: [ 
    AppComponent, 
    ... 
    CollectionInfo, 
    CollectionComponent 
    ], 
    imports: [ 
    ], 
    providers: [ 
    CollectionComponent 
    ], 
    exports: [ 
    CollectionComponent 
    ], 
    bootstrap: [AppComponent] 
}) 
export class AppModule { } 

collectionsmodule.ts

import ... 

@NgModule({ 
    declarations: [ 
    ], 
    imports: [ 
    ] 
}) 
export class ProfileModule {} 
이 하나는 확실히 엉망

"수출 클래스 ProfileModule은"분명히 어떤 이해가되지 않습니다 . 씨 서식 파일의 다른 구성 요소에서 복사했습니다. 나는 지금 "CollectionsModule"로 이름을 바꿀 때, 그것은 또 다른 오류가 발생합니다 :

Error: Cannot find 'ProfileModule' in 'app/collections/collections.module' 

는 "ProfileModule은"다른 곳에서 가져온 것 같은데,하지만 난 곳을 찾을 수 없습니다. 또한 그것이 "NgModule의 일부가 아닙니다"오류에 실제로 영향을 미치는지 확실하지 않습니다.

나는 this very good summary of modules in Angular 4을 읽었지만 여전히 문제를 해결할 수 없습니다.

도움을 주셔서 감사합니다. 그래서 시도

const APP_ROUTES: Routes = [ 
    { path: 'collections', loadChildren: 'app/collections/collections.module#ProfileModule' } 
] 

:

+0

으로 변경해야합니다. 문제를 설명하는 큰 소리로 알려주시겠습니까? –

답변

4

당신은 Providers

@NgModule({ 
    declarations: [ 
    AppComponent, 
    ... 
    CollectionInfo, 
    CollectionComponent 
    ], 
    imports: [ 
    ], 
    providers: [ 
    //remove this CollectionComponent 
    ], 
    exports: [ 
    CollectionComponent 
    ], 
    bootstrap: [AppComponent] 
}) 
export class AppModule { } 
+0

도움을 많이 주셔서 감사합니다! 불행히도이 작동하지 않습니다, 여전히 동일한 오류 메시지 ("오류 : 구성 요소 CollectionComponent 어떤 NgModule 일부 또는 모듈을 모듈로 가져 오지 않았습니다.") – user3255061

0

내부 declarations하지에서 구성 요소를 추가 할 필요가 내 app.routing.ts에서 실수를했다 밝혀 이 파일에 더 이상 존재하지 않는 모듈을로드 할 수 있습니다 (Angular의 오류 메시지가 약간 더 명확했을 수도 있음).또한 내 코드를

const APP_ROUTES: Routes = [ 
    { path: 'collections', component: CollectionComponent } 
] 
+0

비록 내가 왜 이해가 안 돼요. 만약 누군가가 미래의 존경과 다른 독자들을 위해 그것을 더 자세히 설명하고 싶다면 더 나은 설명을하는 다른 대답을 받아 들일 수있어서 기쁩니다. – user3255061

관련 문제