【发布时间】:2017-04-22 01:08:02
【问题描述】:
我在远程数据源中有以下项目(非常简化)
[
{
"id": "3",
"card_name": "Free Beer!",
"count": "1"
}
]
我有一个带有 NG-REPEAT 的 DIV(再次大大简化)
<div ng-repeat="card in cardDetails">
<h1>{{card.card_name}}</h1>
<button ng-style="set_hide(card)">Claim Me</button>
</div>
以及我的控制器中的以下内容
$scope.set_hide = function (card) {
if (card.count > 0) {
return { display:none }
} else {
return { display:block }
}
}
所以基本上如果这张卡的计数不为零(1+),按钮应该显示:无并消失
其余信息(即卡名)按预期呈现,如果我还添加{{card.count}},则按预期显示为 1
但什么也没有发生。没有错误,什么都没有
为什么我的 ng-style 没有触发
提前感谢您的任何指导
【问题讨论】:
标签: angularjs function conditional-statements ng-style