HI,
I have a problem, I want to get data from database and it works. Next I want to put my objects into an array, but I get an error: Cannot read property ‘landmarks’ of undefined.
public landmarks;
And I initializing this in the constructor. Then
fun(){
this.LandmarkRef.once("value", function (snapshot) {
snapshot.forEach(function (childSnapshot) {
var newLandmark = childSnapshot.val();
this.landmarks.push(new Landmark(newLandmark._id, newLandmark._latitude, newLandmark._longitude, newLandmark._title));
})
})
}
I want to use this array in different function. I have no idea, how to get data from database to array and use it later.