Ich bin mit einem kleinen Problem mit Firebase und angular2 konfrontiert. Ich lade eine kleine Aufgabe und Benutzer können sich auf sie bewerben.Firebase Snapshot ändern und angular2
loadTask() {
let post = []
const publicationRef = this.rootRef.child('task').child('attente');
const usersR = this.rootRef.child('users')
return Observable.create((observer) => {
this.geoQuery.on("key_entered", function(key, location, distance){
publicationRef.child(key).on('value', snapshot => {
const taskkey = snapshot.key()
snapshot.forEach((data) => {
const datakey = data.key();
const dataVal = data.val();
usersR.orderByKey().equalTo(dataVal.user).on('child_added', snapshot => {
console.log({key: datakey,nom: snapshot.val().nom, distances: distance})
post.push({nom: dataVal.nom, key: datakey,unom: snapshot.val().nom, uprenom: snapshot.val().prenom, distance: Math.floor(distance), uimage:snapshot.val().image, budget: dataVal.budget, description: dataVal.description, date:dataVal.date, location: dataVal.location, user: dataVal.user, id1: taskkey, id:datakey})
observer.next(post)
})
})
})
})
})
}
alle die Aufgabe angezeigt, aber wenn ich auf eine Aufgabe gelten, in dem dom nennt es eine neue Push-Methode, so eine neue Aufgabe mit dem gleichen Wert angezeigt und disseapear wenn ich die Seite neu zu laden. Ich habe versucht, die Push-Methode
loadTask() {
const publicationRef = this.rootRef.child('task').child('attente');
const usersR = this.rootRef.child('users')
return Observable.create((observer) => {
this.geoQuery.on("key_entered", function(key, location, distance){
publicationRef.child(key).on('value', snapshot => {
const taskkey = snapshot.key()
snapshot.forEach((data) => {
const datakey = data.key();
const dataVal = data.val();
usersR.orderByKey().equalTo(dataVal.user).on('child_added', snapshot => {
console.log({key: datakey,nom: snapshot.val().nom, distances: distance})
const publicio = [{nom: dataVal.nom, key: datakey,unom: snapshot.val().nom, uprenom: snapshot.val().prenom, distance: Math.floor(distance), uimage:snapshot.val().image, budget: dataVal.budget, description: dataVal.description, date:dataVal.date, location: dataVal.location, user: dataVal.user, id1: taskkey, id:datakey}]
observer.next(publicio)
})
})
})
})
})
}
gelten für eine Aufgabe zu entfernen, hat leider keine neue Daten mit dem gleichen Wert hinzufügen, aber in dem dom es nur einen Satz von Daten laden und nicht alle von ihnen
hi adem danke dir für dich anwser, ich habe es schon versucht, funktioniert nicht – PrinceZee