저는 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' }
]
:
으로 변경해야합니다. 문제를 설명하는 큰 소리로 알려주시겠습니까? –