ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 254.2k

How to add keys to content body variable when display data d

May 20 2020 7:13 PM
I work on angular 7 app I display data and column headers dynamically
 
I show content data without header by using content Body Variable
 
but problem I face is cannot catch data values or catch data cell values so that
 
I need to add key to content body
 
my ts code
  1. this._displayreport.GetReportDetailsPaging(this.searchData).subscribe((data: any[]) => {  
  2. this.reportdetailslist = data;  
  3. this.headerCols = Object.keys(data[0]);  
  4. data.forEach((item) =>{  
  5. let values = Object.keys(item).map((key)=> item[key])  
  6. this.contentBody.push(values);  
  7. });  
to get contentbody data I do
  1. <tr *ngFor="let rep of contentBody">  
  2. <td *ngFor="let r1 of rep"><span>{{r1}}</span></td>  
  3. <td  
  4. </tr>  
Result Returned
 
ReportId    onlineurl              reportdate
1222          localhost:5000/    12-12-2018
 
data current for content body displayed on browser console as :
0:["1222","localhost:5000/","12-12-2018"]
 
Expected Result i need to content body display as below
0:[{revisionid:"1222",onlineurl:"localhost:5000/",reportdate:"12-12-2018"}]

Answers (1)