How to handle component.html headers and data in case of data and header columns changed every time ?
I work on angular app give it report id then it returned different result depend on report id
so may be if i pass reportid =1 it display
- FinancialId FinancialName FinancialDate
- 1 cash 12/01/2020
if I pass reportid=2 then it display
- InventoryId InventoryName InventoryQty InventoryPrice
- 1 Stor1 10 50
then it return data different and column headers different based on report id
so How to display this data dynamically on html component .
service.ts
- export class DisplayreportService
- {
- constructor(private http : HttpClient) { }
- GetReportDetailsByReportId(id : string){
- return this.http.get('http://localhost:61265/api/report/Getreportdetails/id=' + id) .map(res=>res); } }
on reportdetails.component.ts
- reportdetailslist: any[];
- constructor(private router: ActivatedRoute, private _displayreport: DisplayreportService) { }
- ngOnInit() {
- const paramIndex = window.location.href.indexOf('id=');
- if (paramIndex > 0) { let param = window.location.href.substring(paramIndex);
- let param1 = param.split('&')[0];
- let param2 = param.substr(param.indexOf('=') + 1);
- this._displayreport.GetReportDetailsByReportId(param2).subscribe((data: any[]) => { this.reportdetailslist = data; });
How to show data on component.html below
class="table table-hover" >
- i dont know table header returned
"let rep of reportdetailslist"> - idont know columns returned
5 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Siddharth GajbhiyePosted May 5, 2020, 11:00 PM
ahmed elbarbaryPosted May 5, 2020, 4:43 PM
ahmed elbarbaryPosted May 4, 2020, 2:53 AM
ahmed elbarbaryPosted May 4, 2020, 1:20 AM
Siddharth GajbhiyePosted May 4, 2020, 12:01 AM