Показать сообщение отдельно
  #1 (permalink)  
Старый 16.03.2017, 10:24
Новичок на форуме
Отправить личное сообщение для AntonEvseev Посмотреть профиль Найти все сообщения от AntonEvseev
 
Регистрация: 16.03.2017
Сообщений: 6

Фильтрация по дате
Есть такой код. Я вывожу ссылками список игр при клике на которые выводится информация по игрокам в таблице.
Код:
<div class="row">
            <div class="col-xs-12 col-sm-12 col-md-3">
                <ul ng-repeat="game in games">
                    <li><a ng-click="sort(game.Name)">{{game.Name}}</a></li>
                </ul>
            </div>
            <div class="col-xs-12 col-sm-12 col-md-9">
                <table ng-show="onTable" ng-table="tableParams" class="table table-bordered table-hover" style="width:500px;margin-left:auto;margin-right:auto;">
                    <tr>
                        <th ng-show="onId">#</th>
                        <td>Name</td>
                        <th>MaxScore</th>
                        <th>GamerDate</th>
                        <th ng-show="onId">Id</th>
                        <th ng-show="onId">Game</th>
                    </tr>
                    <tr ng-repeat="gamer in gamers | filter : filters">
                        <td ng-show="onId">{{ gamer.Id }}</td>
                        <td>{{ gamer.Name }}</td>
                        <td>{{ gamer.MaxScore }}</td>
                        <td>{{ gamer.GamerDate | date :'yyyy-MM-dd' }}</td>
                        <td ng-show="onId">{{ gamer.Game.Id }}</td>
                        <td ng-show="onId">{{ gamer.Game.Name }}</td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
var app = angular.module('app', []);
app.controller('AppController', function ($scope, $http, GamersService, GamesService) {

    $scope.onId = false;
    $scope.onTable = false;
    $scope.gamers = null;
    $scope.filters = {};
      
    $scope.sort = function (value) {
        $scope.onTable = true;
        $scope.filters = value;
    }
   
    GamersService.GetAllRecords().then(function (d) {
        $scope.gamers = d.data;
    }, function () {
        alert('Ошибка соединения с базой данных !!!');
    });

    GamesService.GetAllGames().then(function (d) {
        $scope.games = d.data;
    }, function () {
        alert('Ошибка соединения с базой данных !!!');
    });
    
});


app.factory('GamersService', function ($http) {
    var fac = {};
    fac.GetAllRecords = function () {
        return $http.get('/api/Leader/');
    }
    return fac;
});

app.factory('GamesService', function ($http) {
    var fac = {};
    fac.GetAllGames = function () {
        return $http.get('/api/game/');
    }
    return fac;
});

Мне надо добавить табы к таблицам, чтобы фильтровать по столбцу GamerDate в разрезе день/неделя/All time. Как это сделать?

Последний раз редактировалось AntonEvseev, 16.03.2017 в 10:35.
Ответить с цитированием