我有以下表格和表格:
<div data-ng-controller="ctrl">
<form>
<input type="text" data-ng-model="VA" />
<input type="text" data-ng-model="VB" />
<p class="ratio">{{VA / VB}}</p>
</form>
<table>
<caption>Classification</caption>
<tr>
<td>Low</td>
</tr>
<tr>
<td>Medium</td>
</tr>
<tr>
<td>High</td>
</tr>
</table>
</div>
当VA和VB都与null不同时,我想在p标签上显示比例,并根据规则将TR的类更改为高亮显示:
ratio < 0.4 => Low
0.4 <= ratio <= 0.8 => Medium
ratio > 0.8 => High
我该怎么做?我需要一个控制器吗? 这不能直接在HTML上制作吗?
答案 0 :(得分:0)
类似的东西:
<form>
<input type="text" data-ng-model="VA" />
<input type="text" data-ng-model="VB" />
<p ng-show="!!(!!VA && !!VB)" class="ratio">{{VA / VB}}</p>
</form>
<table>
<caption>Classification</caption>
<tr ng-class="{ratio<0.4:'low', ratio=<0.8 && ratio>=0.4:'medium', ration>0.8:'high'}">
<td>Low</td>
</tr>
<tr>
<td>Medium</td>
</tr>
<tr>
<td>High</td>
</tr>
</table>
</div>