Angular JS:需要刷新表头

时间:2015-04-27 19:44:49

标签: angularjs

我使用标准HTML表来表示网格,并有一个名为Reset的按钮来重置默认的排序和方向。但我无法看到反映重置操作的表格视图。

以下是我的代码段

<div class="col-md-12 SearchScrollFrame">
  <table class="table table-condensed table-bordered">
   <thead>
      <tr>          
        <th><a href="" ng-click="toggleHeader('patientLastname')">Last Name<span ng-show="$scope.predicate == 'patientLastname'"><span ng-show="!$scope.reverse">&#9650;</span><span ng-show="$scope.reverse">&#9660;</span></span></a></th>
        <th><a href="" ng-click="toggleHeader('patientFirstname')">First Name<span ng-show="$scope.predicate == 'patientFirstname'"><span ng-show="!$scope.reverse">&#9650;</span><span ng-show="$scope.reverse">&#9660;</span></span></a></th>
        <th><a href="" ng-click="toggleHeader('patientHomePhone')">Telephone<span ng-show="$scope.predicate == 'patientHomePhone'"><span ng-show="!$scope.reverse">&#9650;</span><span ng-show="$scope.reverse">&#9660;</span></span></a></th>

      </tr>
    </thead>
    <tr ng-repeat="patient in patients  |  orderBy:$scope.predicate:$scope.reverse | filter:$parent.filterResults " >
        <td>{{patient.patientLastname}} {{$scope.predicate}}</td>
        <td>{{patient.patientFirstname}}</td>           
        <td>{{patient.patientHomePhone}}</td>

    </tr>
  </table>
</div>

function myCtrl($scope,$resource,$window) {
       $scope.resetDefault = function() {
              $scope.predicate = 'patientFirstName';
               $scope.reverse = true;

        };

         $scope.toggleHeader = function( header ){
            console.log(header)
             $scope.predicate = header; 
             $scope.reverse=!$scope.reverse; 
         }
 }

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

例如,您不应在视图中包含public class SubClass extends SuperClass.Impl { @Override public void doSomething() { super.doSomething(); super.a *= 10; } @Override public void doEverything() { super.doEverything(); this.b += 5; } } - 此ngShow:$scope.应为ng-show="$scope.reverse"

同样ng-show="reverse"应替换为ng-show="$scope.predicate == 'patientLastname'"