user6891871
user6891871

Reputation: 174

ng-repeat is not working inside the table row

I want to fetch the data inside table but not getting any data. Code is here--

 <div ng-controller="tenders"> 
                <table ng-init="getViewProjectDetail('<?php echo $project_id ; ?>')">
                  <thead> 
                        <tr class="active">
                            <th colspan="4">
                                Project Detail:
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <th><b>Project Name :</b></th>
                            <td ng-repeat="a in viewProjects">
                                {{a.id}}
                            </td>
                         {{viewProjects | json}}
                        </tr>
                    </tbody>
                </table>
            </div>

getting all data in viewProjects through json but unable to print it inside table row n each function of controller services and models working perfactly except this.

Please help me to get this issue.

Upvotes: 0

Views: 963

Answers (2)

nativegrip
nativegrip

Reputation: 892

You can use <ng-container ng-repeat=""></ng-container> for any angularJS condition without use any html element as below :

<table>
  <tr>
    <td>xyz</td>
    <ng-container ng-repeat="a in myArray">
      <td>{{a.id}}</td>
    </ng-container>
  </tr>
</table>

Upvotes: 1

Marcus H&#246;glund
Marcus H&#246;glund

Reputation: 16801

It looks like you should loop over tr instead of td in this case

<div ng-controller="tenders"> 
    <table ng-init="getViewProjectDetail('<?php echo $project_id ; ?>')">
      <thead> 
            <tr class="active">
                <th colspan="4">
                    Project Detail:
                </th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="a in viewProjects">
                <td><b>Project Name :</b></td>
                <td >
                    {{a.id}}
                </td>
            </tr>
        </tbody>
    </table>
</div>

Upvotes: 0

Related Questions