0
저는 Firebase에서 데이터를 가져 와서 ngFor 루프의 div 안에 모두 표시하는 프로젝트를 진행하고 있습니다. div를 클릭하면 div에 데이터를 표시하는 모달이 열립니다. 모달을 열기 위해 클릭 할 때를 제외하고는 모든 항목이 작동합니다. 클릭 한 div에 상관없이 첫 번째 div에 대한 데이터 만 표시합니다. 내가 div를 클릭 할 때마다 정확한 데이터를 전달하기 쉬운 것을 간과하고 있기를 바라고 있습니다.루프에 대한 각도 2의 데이터 바인딩
<div *ngFor="let game of games | async; trackBy:trackByGame" (click)="modal.open()">
<gamemodal [game]="game"></gamemodal>
</div>
구성 요소 게임이 중포 기지
export class AppComponent {
@ViewChild(gameModalComponent)
modal: gameModalComponent;
games: FirebaseListObservable<any>;
cwstring = '/Games/5';
trackByGame(game: any){
return game != null ? game.gameid: null;
}
constructor(af: AngularFire) {
this.games = af.database.list(this.cwstring, {
query: {
orderByChild: 'status'
}
})
}
어떤 아이디어에서로드 여기
export class gameModalComponent {
@Input() game: FirebaseListObservable<any>;
constructor() { }
@ViewChild(ModalComponent) modal: ModalComponent;
open() {
this.modal.open();
}
close() {
this.modal.close();
}
}
입니까? 미리 감사드립니다.
controller.ts 코드를 보여주십시오. –
@AlexanderCiesielski'수출 클래스 gameModalComponent { @Input() 게임 : FirebaseListObservable; 생성자() {} @ViewChild (ModalComponent) 모달 : ModalComponent; open() { this.modal.open(); } 닫기() { this.modal.닫기(); } } ' –
dustin486
코드로 답을 수정하십시오. Firebase의 실제 데이터와 함께'games' 변수를 할당하는 부분도 추가하십시오. –