Skip to main content
1 / 2
ita_3y
  • 2,797
  • 2
  • 11
  • 15

同じ値のものは1回しか出さないということで良ければ、
AngularUIを使えばいけそうです。

直前の要素との比較がしたいということであれば、この辺が参考になるかもしれません。
How to obtain previous item in ng-repeat?

var app = angular.module('app', ['ui.filters']);
app.controller('mainController', ['$scope', function($scope) {
    $scope.items = [{
    "item_id": 1,
    "user_id": 1,
    "created_at": "2015-05-09 05:32:00",
  }, {
    "item_id": 2,
    "user_id": 1,
    "created_at": "2015-05-09 05:32:00",
  }, {
    "item_id": 3,
    "user_id": 1,
    "created_at": "2015-05-08 05:32:00",
  }, {
    "item_id": 4,
    "user_id": 1,
    "created_at": "2015-05-09 05:32:00",
  }, {
    "item_id": 5,
    "user_id": 1,
    "created_at": "2015-05-10 05:32:00",
  }, {
    "item_id": 6,
    "user_id": 1,
    "created_at": "2015-05-08 05:32:00",
  }];
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui.min.js"></script>

<div ng-app="app">
  <div ng-controller="mainController">
    <h4>Full:</h4>
    <div ng-repeat="item in items">
      <div>{{item.created_at}}</div>
      <div>{{item.id}}</div>
    </div>

    <h4>Filter:</h4>
    <div ng-repeat="item in items | unique:'created_at'">
      <div>{{item.created_at}}</div>
      <div>{{item.id}}</div>
    </div>
  </div>
</div>

ita_3y
  • 2,797
  • 2
  • 11
  • 15