I have a set of objects on display with the information about that object. I use ng-repeat to show all the objects, but I would now like to implement a filter or function, group objects by month, if i have objects registered in the same month, to show in my index all of the objects with that month

我有一组显示的对象,其中包含有关该对象的信息。我使用ng-repeat来显示所有对象,但我现在想要实现一个过滤器或函数,按月分组对象,如果我有同月注册的对象,则在我的索引中显示该月的所有对象

this is my JSON Array, with the value " upload_date " is where I would like to get the specific month

这是我的JSON数组,值“upload_date”是我想获得特定月份的地方

"_embedded": {
    "incidents": [
        {
            "id": 20,
            "name": "Nombre de incidente",
            "description": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
            "timestamp": "2015-03-13T00:00:00-0600",
            "upload_date": "2015-03-31T23:58:19-0600",
            "archived": false,
            "_links": {
                "self": {
                    "href": "http://incidents-core/app_dev.php/incidents/20"
                },
                "attachments": {
                    "href": "http://incidents-core/app_dev.php/incidents/20/attachments"
                },
                "comments": {
                    "href": "http://incidents-core/app_dev.php/incidents/20/comments"
                }
            }

and here is my html code with ng-repeat, this works

这是我的HTML代码与ng-repeat,这是有效的

<ul class="list" >
               <h1>January</h1><br />**<---- HERE I WOULD LIKE THO SHOW THE MONTH**
               <br />
                <li class="list__item" ng-repeat="incident in incidents">
                    <!-- ngrepeat: mostrar total de incidentes-->
                    <a href="#" data-toggle="modal" data-target="#incidentModal" ng-click="selectIncident($index)">
                        <!-- /.badgetSection-->
                        <figure class="list__item__inner">
                            <div class="bagdets">
                                <span class="glyphicon glyphicon glyphicon-comment"><span> {{incident._embedded.commentsCount}} </span>
                                <span class="glyphicon glyphicon glyphicon-picture"><span> {{incident._embedded.attachmentsCount}} </span>
                            </div>
                            <!-- ./badges -->
                            <div class="incident-image">
                                <img ng-src="{{incident._links.thumbnail.href || 'img/03.jpg'}}">
                                <p class="incident-type"><span>{{incident._embedded.incident_type}}</span>
                                </p>
                            </div>
                            <figcaption>
                                <p>{{incident.name}}</p>
                                <div class="line-separator"></div>
                                <p>{{incident.description | strLimit: 90 }}</p>
                                <div class="line-separator"></div>
                                <p><span class="glyphicon glyphicon-calendar"></span> {{incident.timestamp | date:'EEE - dd/mm/yyyy'}} <span class="glyphicon glyphicon-time"></span> {{incident.timestamp | date:'hh:mm:ss a'}}</p>
                                <div class="line-separator"></div>
                                <p> <span class="glyphicon glyphicon-user"></span> {{incident._embedded.employee}}</p>
                            </figcaption>
                        </figure>
                    </a>
                </li>
            </ul>

My idea is to try and show all registered objects sorted by month , if there are no objects in that month , just do not show the month. But I don't know how can I grouping by months

我的想法是尝试显示按月排序的所有已注册对象,如果该月没有对象,则不显示月份。但我不知道我怎么能按月分组

2 个解决方案

#1


check this angular-filter which provides so many options https://github.com/a8m/angular-filter

检查这个角度过滤器,它提供了很多选项https://github.com/a8m/angular-filter

更多相关文章

  1. 对象的属性也要加引号吗
  2. 在javascript中过滤对象对象(过滤还是减少?)
  3. JavaScript系列----面向对象的JavaScript(2)
  4. 当鼠标悬停在顶部的对象上时,SVG悬停被取消
  5. Javascript 面向对象编程(一):封装
  6. JavaScript循环输入创建一个对象数组
  7. 如何从json对象获取匹配元素的索引?
  8. JavaScript:使用函数参数检索javascript对象键
  9. JavaScript 对象属性作实参以及实参对象的callee属性

随机推荐

  1. android解析xml文件的方式(其一)
  2. Android开发者已经度过了初级吗
  3. Fedora 下配置 Android 开发环境
  4. Android(安卓)listview与adapter用法
  5. Android(安卓)Fragment 真正的完全解析(下
  6. Android面试系列文章2018之Android部分之
  7. Padding与绘制区域--android:clipToPaddi
  8. Android svg图片使用
  9. Android selector 状态选择器
  10. Android 模拟J2me 通过连接框架