【问题标题】:Multiple radio button groups within angular ng-repeat角度 ng-repeat 中的多个单选按钮组
【发布时间】:2016-07-27 01:22:37
【问题描述】:

我有一个 html 表,我正在使用 ng-repeat 来显示来自数组的显示数据

<table class="table">
<thead>
    <tr>
        <th>Group</th>
        <th>Select</th>
    </tr>
</thead>
<tr ng-repeat="foo in bars">
    <td>{{foo.Group}}</td>
    <td><input type="radio" name="foo.Group" ng-model="foo.Field1"/></td>
</tr>

数组条中的行有一个组字段。我希望为每个组选择唯一的单选按钮。

非常感谢所有帮助。

【问题讨论】:

标签: javascript html angularjs radio-button angularjs-ng-repeat


【解决方案1】:

看来您只是缺少 name 属性上的大括号来正确地将组分配给它。

<table class="table">
<thead>
    <tr>
        <th>Group</th>
        <th>Select</th>
    </tr>
</thead>
<tr ng-repeat="foo in bars">
    <td>{{foo.Group}}</td>
    <td><input type="radio" name="{{foo.Group}}" ng-model="foo.Field1"/></td>
</tr>

【讨论】:

    猜你喜欢
    • 2014-08-10
    • 2016-12-03
    • 2015-08-24
    • 1970-01-01
    • 2018-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多