问题
This my data in firebase
getStudentStage4(){
this.itemArray = []
this.itemList = this.db.list('/users')
this.itemList.snapshotChanges()
.subscribe(actions=>{
actions.forEach(action=>{
let y = action.payload.toJSON()
y["key"] = action.key
this.itemArray.push(y as Users)
})
console.log(this.itemArray[0])
})
}
result console get object info user .
{…}
displayName: "Ameer Amjed"
email: "ameer32o@csad.com"
key: "Ameer Amjed"
rule: "student"
stage: "stage4"
<prototype>: Object { … }
I just need to get stage "stage4" from this array.
回答1:
If itemArray contains all the data, you can use map like so:
const stage = this.itemArray.map(item => {
return item.stage
});
console.log(stage);
来源:https://stackoverflow.com/questions/62501749/get-list-user-firebase-angular