如何评估视图中的表达式(How to evaluate expression in view)
在我的下面的代码中,我正在创建一个HTML table ,其table headers as First, second, Third row for each student 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>In my following code i am creating an HTML table with table headers as First, second, Third and than row for each student.
Depending upon score, I need to put X in cell under relevant column header. Example
If score 10 than put X under First If score 9 than put X under second If score 8 than put X under thirdCan i re-write<td>{{score.Position}}</td> based on above requirement as following.
e.g. <td>{{score.Position}} == 10 ? X :'' </td> <td>{{score.Position}} == 9 ? X :'' </td>Code:
<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>最满意答案
做这个
<td>{{score.Position == 10 ? 'X' : ''}}</td>或这个
<td><span data-ng-if="score.Position==10">X</span></td>Do this
<td>{{score.Position == 10 ? 'X' : ''}}</td>Or this
<td><span data-ng-if="score.Position==10">X</span></td>更多推荐
发布评论