在我的以下代码中,我创建了一个HTML table
table headers as First, second, Third
而不是row for each student
。
根据得分,我需要将X
放在相关列标题下的单元格中。
示例
If score 10 than put X under First
If score 9 than put X under second
If score 8 than put X under third
我可以根据以上要求重新编写<td>{{score.Position}}</td>
,如下所示。
e.g.
<td>{{score.Position}} == 10 ? X :'' </td>
<td>{{score.Position}} == 9 ? X :'' </td>
代码:
<table>
<thead>
<tr>
<td></td>
<td>First</td>
<td>Second</td>
<td>Tbhird</td>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="student in Students">
<td>{{student.Name}}</td>
<td>{{score.Position}}</td>
</tr>
</tbody>
</table>
答案 0 :(得分:4)
这样做
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="wrapper">
Lorem Ispum Lorem Ispum Lorem Ispum Lorem Ispum <br/>
Lorem Ispum Lorem Ispum Lorem Ispum Lorem Ispum <br/>
Lorem Ispum Lorem Ispum Lorem Ispum Lorem Ispum <br/>
Lorem Ispum Lorem Ispum Lorem Ispum Lorem Ispum
</div>
<hr />
或者这个
<td>{{score.Position == 10 ? 'X' : ''}}</td>