【问题标题】:Button click doesn't work in table column按钮单击在表格列中不起作用
【发布时间】:2015-05-20 01:43:20
【问题描述】:

我创建了一个表格,并在每个值单元格的右上角添加了一个按钮。我还添加了 ng-click,但它不起作用,而同一段代码对其他按钮有效。

<table class="table table-bordered">
    <thead>
        <tr>
            <th>Parameter</th>
            <th>Value</th>
        </tr>
    </thead>
    <tr ng-repeat="singleConfig in allConfigDatabase | filter:searchParameter">
        <td>{{singleConfig.parameter}}</td>
        <td>
            <span class="updateButton">
                <button type="button" ng-click="confirmationForm=true;showBasicForm=true">
                    <span class="glyphicon glyphicon-pencil"></span>
                </button>
            </span>{{singleConfig.value}}
        </td>
    </tr>
</table>

【问题讨论】:

  • 您有任何控制台错误吗?你能举一个这些按钮工作的例子吗?
  • 数据库类型和你的angularjs版本是什么?
  • 更多细节请...
  • 我现在没有任何数据库连接,我正在使用 angular 1.3.15

标签: angularjs


【解决方案1】:

您的问题有一个很好的answer

似乎ng-repeat 创建了新范围,所以你必须使用:

$parent.confirmationForm = true;

为了更准确,您需要仅在原语上使用 $parent,如果您尝试更改对象,则无需使用 $parent 范围即可。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-05
    • 2021-09-21
    • 2014-05-27
    • 2021-03-31
    • 2018-11-10
    相关资源
    最近更新 更多