gpt4 book ai didi

javascript - Angular 101 : ngShow using object property not working

转载 作者:行者123 更新时间:2023-12-03 11:59:14 25 4
gpt4 key购买 nike

少说“不工作”,多说“我认为我做得不对”。以下是相关标记:

<select ng-model="strength">
<option selected="selected" value="ALL">All</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>


<table style="" class="table table-striped table-hover table-condensed">
<tbody>
<tr ng-show="row.strength" ng-repeat="row in yearly | orderBy:'-year'">
<td>{{row.season | season}}</td>
<td>{{row.strength}}</td>
<td>{{row.n}}</td>
<td>{{row.a}}</td>
</tr>
</tbody>
</table>

目的是让每一行的强度为 ALL123.我想根据所选值显示/隐藏行。这是最好的方法吗?

最佳答案

如果我正确地理解了您的意图,那么您需要在此处使用表达式。 ng-show="row.strength === 强度"

另请注意,您可以通过 ng-repeat 实现相同的结果,并使用过滤器忽略与strength 不匹配的值。不过,我认为这里的 ng-show 已经足够清楚了。

关于javascript - Angular 101 : ngShow using object property not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25476746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com