【问题标题】:angularjs set checkbox checked using expressionangularjs设置复选框使用表达式检查
【发布时间】:2015-11-26 17:23:02
【问题描述】:

我正在尝试为 ng-repeat 中的复选框设置 checked = "checked"

我当前的代码是:

<tr ng-repeat="current in listobjects" on-list-displayed>
    <input type="checkbox" name = "status" value="1" {{ current.status > 0 ? ' checked="checked"' : '' }}>
</tr>

但是

{{ current.status > 0 ? ' checked="checked" : "" }}

不被angularjs解析并显示为文本

怎么了?

【问题讨论】:

  • 尝试使用ng-checked。例如。 ng-checked="current.status &gt; 0"

标签: angularjs checkbox


【解决方案1】:

为此使用 ng-checked

<tr ng-repeat="current in listobjects" on-list-displayed>
    <input type="checkbox" name = "status" value="1" ng-checked="current.status > 0">
</tr>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-31
    • 2021-09-28
    • 1970-01-01
    • 2014-09-05
    • 1970-01-01
    相关资源
    最近更新 更多