I'm new user for angular and firebase. I used to AngularFireDatabase to get data from firebase real time database. I need to read last updated data in database. I used below code to read it.
items: Observable<any[]>;
constructor(public db: AngularFireDatabase) {
this.items = db.list('DistanceVariationForDiffUserMockDataInfo', ref => ref.orderByChild("distance").limitToLast(1)).valueChanges();
}
I need to assign distance variable from database to another variable in my code. How to do it. Please give me a support to do that.
I need to get below output by using distance value. it's distance value is 5. I need to get that distance from my database.

I already found the minimum and maximum distance to cells from point 0. I require to color the relevant cells when selecting a distance. Distance taken from firebase database.
cells= [
{ id: 1, minDistance: 0.0, maxDistance: 1.4142135623730951 },
{ id: 2, minDistance: 1.0, maxDistance: 2.23606797749979 },
{ id: 3, minDistance: 2.0, maxDistance: 3.1622776601683795 },
{ id: 4, minDistance: 3.0, maxDistance: 4.123105625617661 },
{ id: 5, minDistance: 4.0, maxDistance: 5.0990195135927845 },
{ id: 6, minDistance: 5.0, maxDistance: 6.082762530298219 },
{ id: 7, minDistance: 6.0, maxDistance: 7.0710678118654755 },
{ id: 8, minDistance: 7.0, maxDistance: 8.06225774829855 },
{ id: 9, minDistance: 8.0, maxDistance: 9.055385138137417 },
{ id: 10, minDistance: 9.0, maxDistance: 10.04987562112089 },
Some cells in my code.
getCellColor(cell){
if (this.distance >= cell.minDistance && this.distance <= cell.maxDistance && this.distance > 0 ) {
return "red";
} else{
return "green";
}
}
Used to filter cells after giving distance.