Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
Read Observable array data in angular

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();

}

My database structure enter image description here

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. enter image description here

enter image description here

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!