How to call object value in ionic 2


#1

After done the api calling. in my db i have set of json object values. The structure is look like this :

{
  "status": 1,
  "message": "List Successfully fetched",
  "CatgeoryList": [
    {
      "CatID": "10"
      
    },
{
      "CatID": "30"
     
    },
{
     
     "CatID": "0"
     
    }]
}

I have done api calling. And i get the status == 1. And i can print all the object values under in CatgeoryList. But i want to print all the catID UNDER IN CatgeoryList. i was not able to get.

here my code :

this.authService.categ(this.loginData).then((result) => {
      this.loading.dismiss();
      this.data = result;

       if(this.data.status == 1)
       {
       this.Catdata = this.data.CatgeoryList;  
      console.log(this.Catdata);  // i am getting all data

      this.Catdatanames = this.Catdata.CategoryName;  // not working
      console.log(this.Catdata.CategoryName); // not working
}
}

I want to get the catID underCatgeoryList. Please help me out how can i do that in ionic 2. I searched in google about json parsener or json stringify . But not able to get correctly.Please help me out !


#2

CategoryList is an array with objects inside. these objects have a catId property. you can access them with
this.Catdata.forEach(category => console.log(category.CatID));