0

I have multiple source of income that I want displayed into a table. I will be importing more than 2 values and I want to be able to put them side by side for easy comparing. However, the code below is definitely not working. https://plnkr.co/edit/Vkcc9YUnEIc3PuuS8Yv3?p=preview

<table>
<tr>
    <td ng-repeat="type in informationNames">{{type}}>
    </td>
    <td ng-repeat="type in informationValues1">{{type}}>
    </td>
    <td ng-repeat="type in informationNameValues2">{{type}}>
    </td>
</tr>
</table>

I found this but this doesn't really apply since it is only 1 array and I'll be importing 2+. Angular ng-repeat in table

4
  • Can you provide a working example? jsfiddle.net Commented Aug 29, 2016 at 20:49
  • 1
    it doesn't help us if your not providing code for the controller, informationNames could be undefined or a fire breathing unicorn for all we know Commented Aug 29, 2016 at 20:50
  • Instead of having three lists of single values you should create one list with three properties: {informationName, informationValue, informationNameValue } and do the repeat on the row. Commented Aug 29, 2016 at 20:58
  • Added a Plunker link, plnkr.co/edit/Vkcc9YUnEIc3PuuS8Yv3?p=preview. @mparnisari Commented Aug 29, 2016 at 21:08

1 Answer 1

1

you could place each repeat into a different row so your code would look like:

<table>
  <tr>
    <td ng-repeat="type in informationNames">{{type}}
    </td>
  </tr>
  <tr>
    <td ng-repeat="type in informationValues1">{{type}}
    </td>
   </tr>
   <tr>
    <td ng-repeat="type in informationNameValues2">{{type}}
    </td>
   </tr>
  </table>

this way they are all listed veritally

if you want them horizontally and you know all of the list are the same length you can do it like this:

`

<table>
     <tr ng-repeat="name in informationNames">
      <td>{{name}}
     </td>
      <td>
       {{informationValues1[$index]}}
      </td>
      <td>
        {{informationNameValues2[$index]}}
      </td>
    </tr>
  </table>
Sign up to request clarification or add additional context in comments.

4 Comments

I want them side by side. It looks cleaner.
@SamBush do you mean have the information oriented horizontally? Also does the information have to be in different lists?
each list will be updates dynamically so they will need to stay seperate. It doesn't really need to be a table either. I was just toying with creating 3 <li> tags even. Honestly as long as they display like Name value value on every line I don't really care.
changed my answer to reflect horizontal presentation

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.