pooja shah pooja shah - 1 month ago 16
AngularJS Question

ng-repeat ($last) element with ng-if

var dataList = [{Id:1,Name: "xyz",Select: true},
{Id:2,Name: "PQR",Select : false }];
var headerList = [{"ID","Name","null"}]


i got this value from server side i can not make any changes in this array list.

My html code is

<table class= "table table-bordered">
<thead>
<tr ng-repeat="header in headerList">
<td ng-if="!$last">
{{header}}
</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="data in dataList">
<td ng-repeat="value in data" ng-if="!$last">
{{value}}
</td>
</tr>
</tbody>
</table>


I don't want to generate "Select" column. code works propely , but when bordered class applies on table one blank column is display i.e "Select"

so that how can i remove this blank column in html DOM ?

Answer

You might want to write

    <thead>
       <tr>
          <td ng-if="!$last" ng-repeat="header in headerList">
             {{header}}
          </td>
       </tr>
    </thead>

instead of this

<thead>
   <tr ng-repeat="header in headerList">
      <td ng-if="!$last">
         {{header}}
      </td>
   </tr>
</thead>