过滤器停止工作..显示空白页

时间:2016-06-11 03:44:05

标签: angularjs angularjs-directive angularjs-scope

当我点击我的标题时,它不会排序,表格会消失

angular.module('maniaApp')
  .controller('EventCtrl', function ($scope,$location,$http) {


    $scope.sortType     = '_source.event_name'; // set the default sort type
    $scope.sortReverse  = false;  // set the default sort order
    $scope.searchEvent   = '';     // set the default search/filter term

    var url = "http://api.loc/events/get-events";

    $http.get(url).success(function api(data, status, headers, config){
      $scope.events = data;
    }).error(function api(data, status, headers, config){
      console.error(data, status, headers, config);
    });

这是我的HTML

<div class="container">
  <!--<div ng-view=""></div>-->
  <div ng-controller="EventCtrl">
    <div class="alert alert-info">
      <p>Sort Type: {{ sortType }}</p>
      <p>Sort Reverse: {{ sortReverse }}</p>
      <p>Search Query: {{ searchEvent }}</p>
    </div>

    <form>
      <div class="form-group">
        <div class="input-group">
          <div class="input-group-addon"><i class="fa fa-search"></i></div>

          <input type="text" class="form-control" placeholder="Search events" ng-model="searchEvent">

        </div>
      </div>
    </form>
    <table class="table table-bordered table-striped">

      <thead>
      <tr>
        <td>
          <a href="#" ng-click="sortType = '_source.id'; sortReverse = !sortReverse">
            Id
            <span ng-show="sortType == '_source.id';" class="fa fa-caret-down"></span>
          </a>
        </td>
        <td>
          <a href="#" ng-click="sortType = '_source.event_name'; sortReverse = !sortReverse">
            <span ng-show="sortType == '_source.event_name';" class="fa fa-caret-down"></span>
            Event Name
          </a>
        </td>
        <td>
          <a href="#" ng-click="sortType = '_source.event_status_id'; sortReverse = !sortReverse">
            <span ng-show="sortType == '_source.event_sid'" class="fa fa-caret-down"></span>
            Event Status
          </a>
        </td>
      </tr>
      </thead>

      <tbody>
      <tr ng-repeat="event in events | orderBy:sortType:sortReverse | filter:searchEvent">
        <td>{{ event._source.event_id }}</td>
        <td>{{ event._source.event_name }}</td>
        <td>{{ event._source.event_sid }}</td>
      </tr>
      </tbody>

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

0 个答案:

没有答案