0

I have a Angular Function

             vm.OpenBManageContractBillingReport = function () {
                 reportService.GetContractBillingList(vm.Search).then(function (response) {
                     console.log(response);
                vm.contractBillingReportList = response;
            }, function (err) {

            });
        };

which gives the output of the list from API and the dynamic list is stored in vm.contractBillingReportList. But the Output may be different According to Start Date and End Date Parameter in vm.search. For Ex:- IF start Date Parameter is 1/1/2018 and End Date Parameter is 31/1/2018 the Result Provides Only One Column January 2018. Similarly, IF start Date Parameter is 1/1/2018 and End Date Parameter is 31/12/2019 the Result Provides 24 Col from January 2018 to December 2019. How Can I bind this data with Header Column in HTML Table?

            <div class="clearfix">
           <div class="reportTable">
               <div class="col-sm-12" style="padding:0;">
                   <table class="table table-bordered">
                       <thead>
                           <tr></tr>
                       </thead>
                       <tbody>
                           <tr ng-repeat="item in vm.contractBillingReportListtrack by $index">
                               <td></td>

                           </tr>
                       </tbody>
                   </table>
               </div>
           </div>
       </div>

1 Answer 1

1

Assuming contractBillingReportList is an array of objects with keys of the object required as header. Just loop for keys in the first element and display those keys as headers.

<tr>
  <th ng-repeat="(header, value) in vm.contractBillingReportList[0]">{{header}}</th>
</tr>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.