I have here a snapshot where it gets the value from my firebase.
Declared Array:
stylesArray: number[];
firebase:
key1: 10
key2: 11
key3: 10
key4: 11
key5: 13
key6: 12
key7: 10
snapshot:
this.style.subscribe(snapshots => {
snapshots.forEach(snapshot => {
this.stylesArray = snapshot.val();
this.stylesArray[0] = snapshot.val();
console.log(snapshot.key)
console.log(snapshot.val())
});
})
console.log(this.stylesArray[0]); // Expected Output should be 10 from Key 1
Where am I doing it wrong?