0

I have data fetched from json and displayed in a table. Im trying to display a header but when i use it displays the data vertically and i want to display it horizontal

Here's my code

<table>
<tr ng-repeat="ninja in ninjass">
<th>
  {{ ninja.name }}
</th>
<td>
  {{ ninja.name }}
</td>
<td>
  {{ ninja.rate }}
</td>
<td>
  {{ ninja.rate }}
</td>
<td>
  {{ ninja.rate }}
</td>
</tr>
</table>

3 Answers 3

1
    <table>
        <th ng-repeat="ninja in ninjclass">
             {{ ninja.name }}
        </th>
        <tbody>
            <tr ng-repeat="ninja in ninjclass">
                <td>{{ ninja.name }}</td>
                <td>{{ ninja.rate }}</td>
            </tr>
        </tbody>
    </table>
Sign up to request clarification or add additional context in comments.

2 Comments

Some explanation makes your answer better to understand
Thanks for the help!
1

The html for your table is wrong. It should be of form:

    <table>
        <thead>
          <th>name</th>
          <th>rate</th>
        </thead>
        <tbody>
          <tr ng-repeat="ninja in ninjclass">
              <td>{{ninja.name}}</td>
              <td>{{ninja.rate}}</td>
          </tr>
        </tbody>
   </table>

1 Comment

is it possible to not have static header?
0
<table>
<tr ng-repeat="ninja in ninjass">
<th>
{{ ninja.name }}
</th>
</tr>

<tr>  <td>{{ ninja.name }}<td> </tr>

<tr>  <td>{{ ninja.name }}<td> </tr>

<tr>  <td>{{ ninja.rate }}<td> </tr>

<tr>  <td>{{ ninja.rate }}<td> </tr>

<tr>  <td>{{ ninja.rate }}<td> </tr>
</table>

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.