如何在ng-click和ng-show中使用表达式

How to use expressions inside ng-click and ng-show

本文关键字:表达式 ng-show ng-click      更新时间:2023-09-26

我试图使一个可扩展的行表。我没有得到任何错误信息,但它不像预期的那样工作。我怀疑我在这里使用ng-show的表达方式有问题?恰好

我代码:

<table class='table'>
    <thead>
      <tr>
        <th>name</th>
        <th>itemOne</th>
        <th>itemTwo</th>
      </tr>
    </thead>
    <tbody ng-repeat="data in tableData| orderBy:'-clintonValuemain'">
      <tr>
        <td>
          <button ng-show="data.expand" ng-click='data.expand = true'>+</button>
          <button ng-show="!data.expand" ng-click='data.expand = false'>-</button>
          <input type="checkbox" class='checkbox'>
          <a rel="noopener" target="_blank" href={{data.url}}>
        {{data.name}}
        </a>
        </td>
        <td>{{data.valueMain}}</td>
        <td>{{data.tValue}}</td>
        <tr>
          <tr ng-show="data.expand" ng-repeat="subs in data.subvalues| orderBy:'-clintonValuesub'" >
            <td>
              {{subs.name}}
            </td>
            <td>
              {{subs.valueSub}}
            </td>
            <td>
              {{subs.tValue}}
            </td>
          </tr>
        </tr>
      </tr>
    </tbody>
  </table>

试试

<button ng-show="data.expand" ng-click='data.expand = false'>-</button>
<button ng-show="!data.expand" ng-click='data.expand = true'>+</button>

更新砰砰作响

https://plnkr.co/edit/sJDFAp1KDvhYh8K3q7z2?p =预览