[SOLVED] Angular. How can I get a value in object that is in array?

Issue

If I need to get 59, how can I do it?

data = [
   {name: 'AK', price: 50, amount: 1, total: 50},

   {name: 'UMP', price: 59, amount: 1, total: **59**}
]

Solution

If data array is static:

 data[1].total   

else

  const getObjectHavingTotal59 = this.data.filter(e=>{
          return e.total===59;
        })

then

getObjectHavingTotal59[0].total;

Answered By – devj

Answer Checked By – Willingham (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *