0

I am trying to displaying the products using Angular JS loop.

<tr ng-repeat="od in OrderDetail">
    <td> {{ od.ProductName }} </td><br />
    <td  align='right'> {{ od.MRP }} </td>
    <td align='right'> {{ od.SellPrice }} </td>
    <td> {{ od.Quantity }} </td>
    <td align='right'> {{ od.Quantity * od.SellPrice | currency:""}}</td>
</tr>

My requirement is display the product name in 1 line, then MRP, sellprice, quantity, total in next line... and so on.

I tried after product name, also i tried using colspan=5 for product name. None of them is working.

Can someone help me on this.

3
  • if you want vertical layout why use <table>? Commented Sep 28, 2015 at 17:08
  • I am not aware about any other way to do it. Can u eloborate on this. Commented Sep 28, 2015 at 17:09
  • Well since <td> are horzontal why not nested <div> or other block elements? Commented Sep 28, 2015 at 17:10

2 Answers 2

4

This might be what you want:

<table>
  <tbody ng-repeat="od in OrderDetail" >
     <tr>
       <td colspan="4"> {{ od.ProductName }} </td>
      </tr>
     <tr>
       <td align='right'> {{ od.MRP }}  </td>
       <td align='right'> {{ od.SellPrice }}</td>
       <td>  {{ od.Quantity }}</td>
       <td align='right'> {{ od.Quantity * od.SellPrice | currency:""}}</td>
     </tr>
    </tbody>
</table>

And yes, it's okay to have more than one <tbody>

EDIT: It's good practice to use :: for variables in ngRepeat, if you are only changing the entire array (such as renewing the array) and not modifying elements in the array. This will reduce the amount of watchers needed.

Sign up to request clarification or add additional context in comments.

Comments

0

You want ng-repeat-start and ng-repeat-end: https://docs.angularjs.org/api/ng/directive/ngRepeat#special-repeat-start-and-end-points

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.