仅当某个键的值不为空时才尝试在 ng-repeat 中显示项目。
这是代码:
<a class="item" href="#" ng-repeat="e in events | orderBy:'match_time'" ng-if="e.match_timer !== NaN && e.match_status !== 'FT'">
e.match_timer 看起来像:
{
match_timer: ""
}
最佳答案
在ng-if
中你可以这样写你的条件
<a class="item" href="#" ng-repeat="e in events | orderBy:'match_time'" ng-if="e.match_timer !== '' && e.match_status !== 'FT'">
这样,它将仅显示那些 e.match_timer
非空且具有除 FT 之外的其他值的元素
关于javascript - ng-if JSON 值不为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27580017/