1
我在離子3應用程序中使用ngx-pipes,因爲我正在從firebase中拉對象。Angular 4 * ngFor,ngx-pipes獲取頂級密鑰的名稱
我找回我的對象,並把它變成我可以在頁面上使用一個變量:
getEvents() {
this.firebaseDatabase.getEvents.subscribe(data => {
console.log("Events ", data);
this.events = data;
}, error => {
console.log("Events ", error);
});
}
我日誌中的數據和它回來像這樣:
eventIDHashed_1:
endDateTime:"tomorrow"
location:"somewhere"
roles:
GyyapYhHQDOriruHLvGPKaTOiRp2:"admin"
startDateTime:"today"
title:"Arisss & Nathan"
type:"wedding"
eventIDHashed_2:
endDateTime:"tomorrow"
location:"somewhere"
roles:
GyyapYhHQDOriruHLvGPKaTOiRp2:"admin"
startDateTime:"today"
title:"Jack & Marlana"
type:"wedding"
的方式我在頁面上顯示它是一個臨時解決方案,但除第一行外,一切工作正常。我需要獲得事件名稱(鍵),它說eventIDHashed_1
和eventIDHashed_2
<div class="event-container">
<div *ngFor="let event of events | values; let i = index">
<span>{{events[i]}}</span>
<span>{{event.title}}</span>
<span>{{event.location}}</span>
<span>{{event.type}}</span>
<span *ngFor="let role of event.roles | pairs">
<span>{{role[0]}}, {{role[1]}}</span>
</span>
<span>{{event.startDateTime}}</span>
<span>{{event.endDateTime}}</span>
</div>
</div>
我所擁有的一切工作,我能夠獲取所有信息,除了實際的事件ID <span>{{events[i] | keys}}</span>
這給了我所有的列表它(endDateTime, location, title, startDateTime...
)裏面的鑰匙,但我需要得到事件的id eventIDHashed_1
和eventIDHashed_2