Typescript 按顺序排列的Firebase列表
我有一个firebase列表,我试图按“时间”节点排序。我怎样才能在打字脚本中做到这一点?谢谢 page.ts:Typescript 按顺序排列的Firebase列表,typescript,firebase,ionic-framework,Typescript,Firebase,Ionic Framework,我有一个firebase列表,我试图按“时间”节点排序。我怎样才能在打字脚本中做到这一点?谢谢 page.ts: // Get Chat Reference chatsProvider.getChatRef(this.company, this.uid, this.interlocutor) .then((chatRef:any) => { this.chats = this.db.list(chatRef); }); ChatProvider
// Get Chat Reference
chatsProvider.getChatRef(this.company, this.uid, this.interlocutor)
.then((chatRef:any) => {
this.chats = this.db.list(chatRef);
});
ChatProvider.ts
// get list of Chats of a Logged In User
getChats() {
return this.up.getCompany().then(company => {
return this.up.getUid().then(uid => {
let chats = this.db.list(`/companies/${company}/users/${uid}/chats`);
return chats;
});
});
}
考虑到您正在使用Angularfire2,您所要做的就是这样
this.chats = this.db.list(chatRef, {
query: {
orderByChild: "time"
});
如果您想按降序获取列表,我建议您将时间存储为负时间戳
您想要订购//Get Chat Reference或//Get Chat list of Chat of a Logged Users的哪种代码看起来您正在使用angularfire2